3#include "libxr_def.hpp"
4#include "libxr_system.hpp"
48 [[nodiscard]] ErrorCode
TryLock();
互斥锁的 RAII 机制封装 (RAII-style mechanism for automatic mutex management).
Mutex & mutex_
被管理的互斥锁 (Reference to the managed mutex).
LockGuard(Mutex &mutex)
构造函数,自动加锁 (Constructor automatically locking the mutex).
~LockGuard()
析构函数,自动解锁 (Destructor automatically unlocking the mutex).
互斥锁类,提供线程同步机制 (Mutex class providing thread synchronization mechanisms).
libxr_mutex_handle mutex_handle_
互斥锁句柄 (Handle for the mutex).
Mutex()
构造函数,初始化互斥锁 (Constructor to initialize the mutex).
ErrorCode Lock()
加锁,如果锁已被占用,则阻塞等待 (Lock the mutex, blocking if it is already locked).
ErrorCode TryLock()
尝试加锁,如果锁已被占用,则立即返回失败 (Attempt to lock the mutex, returning immediately if already locked).
~Mutex()
析构函数,销毁互斥锁 (Destructor to destroy the mutex).
void Unlock()
解锁互斥锁 (Unlock the mutex).