libxr 1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
mutex.cpp
1#include "mutex.hpp"
2
3#include <pthread.h>
4
5#include "libxr_def.hpp"
6#include "libxr_system.hpp"
7
8using namespace LibXR;
9
10Mutex::Mutex() : mutex_handle_(PTHREAD_MUTEX_INITIALIZER) {}
11
13
14ErrorCode Mutex::Lock() {
16 return ErrorCode::BUSY;
17 }
18 return ErrorCode::OK;
19}
20
21ErrorCode Mutex::TryLock() {
23 return ErrorCode::BUSY;
24 }
25 return ErrorCode::OK;
26}
27
29
30ErrorCode Mutex::TryLockInCallback(bool in_isr) {
31 UNUSED(in_isr);
32 return TryLock();
33}
34
36 UNUSED(in_isr);
37 Unlock();
38}
ErrorCode TryLockInCallback(bool in_isr)
在回调(ISR)中尝试加锁 (Attempt to lock the mutex inside an interrupt service routine (ISR)).
Definition mutex.cpp:29
libxr_mutex_handle mutex_handle_
互斥锁句柄 (Handle for the mutex).
Definition mutex.hpp:164
Mutex()
构造函数,初始化互斥锁 (Constructor to initialize the mutex).
Definition mutex.cpp:9
ErrorCode Lock()
加锁,如果锁已被占用,则阻塞等待 (Lock the mutex, blocking if it is already locked).
Definition mutex.cpp:13
ErrorCode TryLock()
尝试加锁,如果锁已被占用,则立即返回失败 (Attempt to lock the mutex, returning immediately if already locked).
Definition mutex.cpp:20
~Mutex()
析构函数,销毁互斥锁 (Destructor to destroy the mutex).
Definition mutex.cpp:11
void UnlockFromCallback(bool in_isr)
在回调(ISR)中解锁 (Unlock the mutex inside an interrupt service routine (ISR)).
Definition mutex.cpp:49
void Unlock()
解锁互斥锁 (Unlock the mutex).
Definition mutex.cpp:27
LibXR Color Control Library / LibXR终端颜色控制库
constexpr auto min(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最小值