1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef BASE_SYNCHRONIZATION_LOCK_IMPL_H_
6 #define BASE_SYNCHRONIZATION_LOCK_IMPL_H_
9 #include "build/build_config.h"
13 #elif defined(OS_POSIX)
17 #include "base/base_export.h"
18 #include "base/basictypes.h"
23 // This class implements the underlying platform-specific spin-lock mechanism
24 // used for the Lock class. Most users should not use LockImpl directly, but
25 // should instead use Lock.
26 class BASE_EXPORT LockImpl {
29 typedef CRITICAL_SECTION OSLockType;
30 #elif defined(OS_POSIX)
31 typedef pthread_mutex_t OSLockType;
37 // If the lock is not held, take it and return true. If the lock is already
38 // held by something else, immediately return false.
41 // Take the lock, blocking until it is available if necessary.
44 // Release the lock. This must only be called by the lock's holder: after
45 // a successful call to Try, or a call to Lock.
48 // Return the native underlying lock. Not supported for Windows builds.
49 // TODO(awalker): refactor lock and condition variables so that this is
52 OSLockType* os_lock() { return &os_lock_; }
58 DISALLOW_COPY_AND_ASSIGN(LockImpl);
61 } // namespace internal
64 #endif // BASE_SYNCHRONIZATION_LOCK_IMPL_H_