1 // Copyright (c) 2011 Google Inc. All rights reserved.
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the
13 // * Neither the name of Google Inc. nor the name Chromium Embedded
14 // Framework nor the names of its contributors may be used to endorse
15 // or promote products derived from this software without specific prior
16 // written permission.
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 // Do not include this header file directly. Use base/cef_lock.h instead.
32 #ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_LOCK_IMPL_H_
33 #define CEF_INCLUDE_BASE_INTERNAL_CEF_LOCK_IMPL_H_
35 #include "include/base/cef_build.h"
39 #elif defined(OS_POSIX)
43 #include "include/base/cef_macros.h"
46 namespace cef_internal {
48 // This class implements the underlying platform-specific spin-lock mechanism
49 // used for the Lock class. Most users should not use LockImpl directly, but
50 // should instead use Lock.
54 typedef CRITICAL_SECTION NativeHandle;
55 #elif defined(OS_POSIX)
56 typedef pthread_mutex_t NativeHandle;
62 // If the lock is not held, take it and return true. If the lock is already
63 // held by something else, immediately return false.
66 // Take the lock, blocking until it is available if necessary.
69 // Release the lock. This must only be called by the lock's holder: after
70 // a successful call to Try, or a call to Lock.
73 // Return the native underlying lock.
74 // TODO(awalker): refactor lock and condition variables so that this is
76 NativeHandle* native_handle() { return &native_handle_; }
79 NativeHandle native_handle_;
81 DISALLOW_COPY_AND_ASSIGN(LockImpl);
84 } // namespace cef_internal
87 #endif // CEF_INCLUDE_BASE_INTERNAL_CEF_LOCK_IMPL_H_