1#ifndef NEFORCE_CORE_ASYNC_MUTEX_HPP__
2#define NEFORCE_CORE_ASYNC_MUTEX_HPP__
12#ifdef NEFORCE_PLATFORM_WINDOWS
22#ifdef NEFORCE_PLATFORM_LINUX
25NEFORCE_BEGIN_NAMESPACE__
49#ifdef NEFORCE_PLATFORM_WINDOWS
122#ifdef NEFORCE_PLATFORM_WINDOWS
189template <typename Mutex>
217 lock& operator=(
const lock&) =
delete;
227struct defer_lock_tag {
228 constexpr defer_lock_tag()
noexcept =
default;
242 constexpr try_lock_tag()
noexcept =
default;
256template <
typename Mutex>
263 bool owns_lock_ =
false;
304 owns_lock_(m.try_lock()) {}
316 mutex_(other.mutex_),
317 owns_lock_(other.owns_lock_) {
318 other.mutex_ =
nullptr;
319 other.owns_lock_ =
false;
336 mutex_ = other.mutex_;
337 owns_lock_ = other.owns_lock_;
338 other.mutex_ =
nullptr;
339 other.owns_lock_ =
false;
358 NEFORCE_NODISCARD
explicit operator bool() const noexcept {
return owns_lock_; }
364 NEFORCE_NODISCARD
bool owns_lock() const noexcept {
return owns_lock_; }
417 owns_lock_ = mutex_->try_lock();
439NEFORCE_END_NAMESPACE__
bool try_lock() noexcept
尝试锁定互斥锁
::pthread_mutex_t native_handle_type
互斥锁的系统句柄类型
const native_handle_type * native_handle() const noexcept
获取常量原生句柄
native_handle_type * native_handle() noexcept
获取原生句柄
bool try_lock() noexcept
尝试锁定递归互斥锁
::pthread_mutex_t native_handle_type
递归互斥锁的系统句柄类型
const native_handle_type * native_handle() const noexcept
获取常量原生句柄
native_handle_type * native_handle() noexcept
获取原生句柄
bool try_lock() noexcept
尝试锁定互斥锁
unique_lock(mutex_type &m, try_lock_tag tag) noexcept
尝试锁定构造函数
unique_lock(mutex_type &m)
从互斥锁构造
mutex_type * release() noexcept
释放所有权
NEFORCE_NODISCARD mutex_type * mutex() const noexcept
获取管理的互斥锁指针
unique_lock(mutex_type &m, defer_lock_tag tag) noexcept
延迟锁定构造函数
NEFORCE_NODISCARD bool owns_lock() const noexcept
检查是否拥有锁
unique_lock()=default
默认构造函数
unique_lock & operator=(unique_lock &&other) noexcept
移动赋值运算符
unique_lock(unique_lock &&other) noexcept
移动构造函数
NEFORCE_NODISCARD constexpr T * addressof(T &x) noexcept
获取对象的地址
NEFORCE_INLINE17 constexpr try_lock_tag try_lock
尝试锁定标签实例
NEFORCE_INLINE17 constexpr defer_lock_tag defer_lock
延迟锁定标签实例