#ifndef BASE_SYNCHRONIZATION_LOCK_IMPL_H_
#define BASE_SYNCHRONIZATION_LOCK_IMPL_H_
#include <utility>
#include "base/base_export.h"
#include "base/check.h"
#include "base/dcheck_is_on.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "base/memory/stack_allocated.h"
#include "base/synchronization/lock_subtle.h"
#include "base/thread_annotations.h"
#include "build/build_config.h"
#if BUILDFLAG(IS_WIN)
#include "base/win/windows_types.h"
#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
#include <errno.h>
#include <pthread.h>
#include <string.h>
#endif
namespace base {
class Lock;
class ConditionVariable;
namespace win {
namespace internal {
class AutoNativeLock;
class ScopedHandleVerifier;
}
}
namespace internal {
class BASE_EXPORT LockImpl { … };
void LockImpl::Lock() { … }
#if BUILDFLAG(IS_WIN)
bool LockImpl::Try() {
return !!::TryAcquireSRWLockExclusive(
reinterpret_cast<PSRWLOCK>(&native_handle_));
}
void LockImpl::Unlock() {
::ReleaseSRWLockExclusive(reinterpret_cast<PSRWLOCK>(&native_handle_));
}
#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
#if DCHECK_IS_ON()
BASE_EXPORT void dcheck_trylock_result(int rv);
BASE_EXPORT void dcheck_unlock_result(int rv);
#endif
bool LockImpl::Try() { … }
void LockImpl::Unlock() { … }
#endif
template <class LockType>
class SCOPED_LOCKABLE BasicAutoLock { … };
template <class LockType>
class SCOPED_LOCKABLE BasicMovableAutoLock { … };
template <class LockType>
class SCOPED_LOCKABLE BasicAutoTryLock { … };
template <class LockType>
class BasicAutoUnlock { … };
template <class LockType>
class SCOPED_LOCKABLE BasicAutoLockMaybe { … };
template <class LockType>
class SCOPED_LOCKABLE BasicReleasableAutoLock { … };
}
}
#endif