|
libxr
Embedded C++ framework for bare-metal, RTOS and Linux
|
互斥锁类,提供线程同步机制 Mutex class providing thread synchronization mechanisms. More...
#include <mutex.hpp>
Classes | |
| class | LockGuard |
| 互斥锁的 RAII 机制封装 RAII-style mechanism for automatic mutex management. More... | |
Public Member Functions | |
| Mutex () | |
| 构造函数,初始化互斥锁 Constructor to initialize the mutex. | |
| ~Mutex () | |
| 析构函数,销毁互斥锁 Destructor to destroy 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. | |
| void | Unlock () |
| 解锁互斥锁 Unlock the mutex. | |
互斥锁类,提供线程同步机制 Mutex class providing thread synchronization mechanisms.
该类实现了一个互斥锁,用于确保多线程环境下的线程安全,支持加锁、解锁,并对中断服务程序(ISR)进行特殊处理。 This class implements a mutex for thread-safe operations, supporting locking, unlocking, and special handling for interrupt service routines (ISR).
| Mutex::Mutex | ( | ) |
| Mutex::~Mutex | ( | ) |
| ErrorCode Mutex::Lock | ( | ) |
加锁,如果锁已被占用,则阻塞等待 Lock the mutex, blocking if it is already locked.
ErrorCode::OK 表示成功 / ErrorCode::OK on success. Definition at line 16 of file mutex.cpp.
|
nodiscard |
尝试加锁,如果锁已被占用,则立即返回失败 Attempt to lock the mutex, returning immediately if already locked.
ErrorCode::OK 表示成功 / ErrorCode::OK on success.ErrorCode::BUSY 表示锁已被占用 / ErrorCode::BUSY if the mutex is already locked. Definition at line 26 of file mutex.cpp.
| void Mutex::Unlock | ( | ) |