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__
45class NEFORCE_API
mutex :
public mutex_base {
51#ifdef NEFORCE_PLATFORM_WINDOWS
123#ifdef NEFORCE_PLATFORM_WINDOWS
190template <typename Mutex>
220 lock& operator=(
const lock&) =
delete;
230struct lock_defer_tag {
231 constexpr lock_defer_tag()
noexcept =
default;
246struct lock_quiet_tag {
247 constexpr lock_quiet_tag()
noexcept =
default;
262template <
typename Mutex>
271 bool owns_lock_ =
false;
312 owns_lock_(m.try_lock()) {}
324 mutex_(other.mutex_),
325 owns_lock_(other.owns_lock_) {
326 other.mutex_ =
nullptr;
327 other.owns_lock_ =
false;
344 mutex_ = other.mutex_;
345 owns_lock_ = other.owns_lock_;
346 other.mutex_ =
nullptr;
347 other.owns_lock_ =
false;
366 NEFORCE_NODISCARD
explicit operator bool() const noexcept {
return owns_lock_; }
372 NEFORCE_NODISCARD
bool owns_lock() const noexcept {
return owns_lock_; }
386 if (mutex_ ==
nullptr) {
402 if (mutex_ ==
nullptr) {
419 if (mutex_ ==
nullptr) {
425 owns_lock_ = mutex_->try_lock();
447NEFORCE_END_NAMESPACE__
const native_handle_type * native_handle() const noexcept
获取常量原生句柄
native_handle_type * native_handle() noexcept
获取原生句柄
::SRWLOCK native_handle_type
互斥锁的系统句柄类型
bool try_lock() noexcept
尝试锁定互斥锁
bool try_lock() noexcept
尝试锁定递归互斥锁
const native_handle_type * native_handle() const noexcept
获取常量原生句柄
::CRITICAL_SECTION native_handle_type
递归互斥锁的系统句柄类型
native_handle_type * native_handle() noexcept
获取原生句柄
unique_lock & operator=(unique_lock &&other) noexcept
移动赋值运算符
mutex_type * mutex() const noexcept
获取管理的互斥锁指针
mutex_type * release() noexcept
释放所有权
unique_lock(mutex_type &m)
从互斥锁构造
unique_lock()=default
默认构造函数
unique_lock(unique_lock &&other) noexcept
移动构造函数
unique_lock(mutex_type &m, lock_defer_tag tag) noexcept
延迟锁定构造函数
unique_lock(mutex_type &m, lock_quiet_tag tag) noexcept
尝试锁定构造函数
bool owns_lock() const noexcept
检查是否拥有锁
bool try_lock() noexcept
尝试锁定互斥锁
constexpr T * addressof(T &x) noexcept
获取对象的地址
constexpr bool is_base_of_v
is_base_of的便捷变量模板
constexpr lock_defer_tag lock_defer
延迟锁定标签实例
constexpr lock_quiet_tag lock_quiet
尝试锁定标签实例