libxr 1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
LibXR::Mutex::LockGuardInCallback Class Reference

回调(ISR)上下文中的互斥锁管理类 (Lock management class for ISR context). More...

#include <mutex.hpp>

Collaboration diagram for LibXR::Mutex::LockGuardInCallback:

Public Member Functions

 LockGuardInCallback (Mutex &mutex, bool in_isr)
 构造函数,尝试在 ISR 上下文中加锁 (Constructor attempting to lock the mutex inside ISR context).
 
 ~LockGuardInCallback ()
 析构函数,自动释放锁(如果成功加锁) (Destructor automatically unlocking the mutex if successfully locked).
 
bool Locked ()
 检查是否成功加锁 (Check if the mutex was successfully locked).
 

Private Attributes

Mutexmutex_
 被管理的互斥锁 (Reference to the managed mutex).
 
ErrorCode success_
 记录加锁的状态 (Stores the lock acquisition status).
 
bool in_isr_
 记录是否处于 ISR 上下文 (Indicates if in ISR context).
 

Detailed Description

回调(ISR)上下文中的互斥锁管理类 (Lock management class for ISR context).

This class attempts to acquire the lock inside an ISR and releases it when the object goes out of scope. 该类尝试在 ISR 中获取锁,并在对象销毁时释放锁。

Definition at line 122 of file mutex.hpp.

Constructor & Destructor Documentation

◆ LockGuardInCallback()

LibXR::Mutex::LockGuardInCallback::LockGuardInCallback ( Mutex mutex,
bool  in_isr 
)
inline

构造函数,尝试在 ISR 上下文中加锁 (Constructor attempting to lock the mutex inside ISR context).

Parameters
mutex需要管理的互斥锁 (Reference to the mutex to manage).
in_isr指示当前是否处于 ISR 上下文 (Indicates if the function is in ISR context).

Definition at line 132 of file mutex.hpp.

134 {
135 }
ErrorCode success_
记录加锁的状态 (Stores the lock acquisition status).
Definition mutex.hpp:159
bool in_isr_
记录是否处于 ISR 上下文 (Indicates if in ISR context).
Definition mutex.hpp:160
Mutex & mutex_
被管理的互斥锁 (Reference to the managed mutex).
Definition mutex.hpp:158
ErrorCode TryLockInCallback(bool in_isr)
在回调(ISR)中尝试加锁 (Attempt to lock the mutex inside an interrupt service routine (ISR)).
Definition mutex.cpp:29
constexpr auto min(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最小值

◆ ~LockGuardInCallback()

LibXR::Mutex::LockGuardInCallback::~LockGuardInCallback ( )
inline

析构函数,自动释放锁(如果成功加锁) (Destructor automatically unlocking the mutex if successfully locked).

Definition at line 141 of file mutex.hpp.

142 {
143 if (success_ == ErrorCode::OK)
144 {
146 }
147 }
void UnlockFromCallback(bool in_isr)
在回调(ISR)中解锁 (Unlock the mutex inside an interrupt service routine (ISR)).
Definition mutex.cpp:49

Member Function Documentation

◆ Locked()

bool LibXR::Mutex::LockGuardInCallback::Locked ( )
inline

检查是否成功加锁 (Check if the mutex was successfully locked).

Returns
如果成功加锁,返回 true,否则返回 false (Returns true if successfully locked, otherwise false).

Definition at line 155 of file mutex.hpp.

155{ return success_ == ErrorCode::OK; }

Field Documentation

◆ in_isr_

bool LibXR::Mutex::LockGuardInCallback::in_isr_
private

记录是否处于 ISR 上下文 (Indicates if in ISR context).

Definition at line 160 of file mutex.hpp.

◆ mutex_

Mutex& LibXR::Mutex::LockGuardInCallback::mutex_
private

被管理的互斥锁 (Reference to the managed mutex).

Definition at line 158 of file mutex.hpp.

◆ success_

ErrorCode LibXR::Mutex::LockGuardInCallback::success_
private

记录加锁的状态 (Stores the lock acquisition status).

Definition at line 159 of file mutex.hpp.


The documentation for this class was generated from the following file: