5 #ifndef V8_BASE_PLATFORM_MUTEX_H_ 6 #define V8_BASE_PLATFORM_MUTEX_H_ 8 #include "src/base/base-export.h" 9 #include "src/base/lazy-instance.h" 11 #include "src/base/win32-headers.h" 13 #include "src/base/logging.h" 37 class V8_BASE_EXPORT
Mutex final {
54 bool TryLock() V8_WARN_UNUSED_RESULT;
58 typedef pthread_mutex_t NativeHandle;
60 typedef SRWLOCK NativeHandle;
63 NativeHandle& native_handle() {
64 return native_handle_;
66 const NativeHandle& native_handle()
const {
67 return native_handle_;
71 NativeHandle native_handle_;
76 V8_INLINE
void AssertHeldAndUnmark() {
83 V8_INLINE
void AssertUnheldAndMark() {
92 DISALLOW_COPY_AND_ASSIGN(
Mutex);
107 #define LAZY_MUTEX_INITIALIZER LAZY_STATIC_INSTANCE_INITIALIZER 152 bool TryLock() V8_WARN_UNUSED_RESULT;
156 typedef pthread_mutex_t NativeHandle;
158 typedef CRITICAL_SECTION NativeHandle;
161 NativeHandle& native_handle() {
162 return native_handle_;
164 const NativeHandle& native_handle()
const {
165 return native_handle_;
169 NativeHandle native_handle_;
192 #define LAZY_RECURSIVE_MUTEX_INITIALIZER LAZY_STATIC_INSTANCE_INITIALIZER 207 enum class NullBehavior { kRequireNotNull, kIgnoreIfNull };
209 template <
typename Mutex, NullBehavior Behavior = NullBehavior::kRequireNotNull>
213 if (Behavior == NullBehavior::kRequireNotNull || mutex_ !=
nullptr) {
218 if (mutex_ !=
nullptr) mutex_->Unlock();
232 #endif // V8_BASE_PLATFORM_MUTEX_H_