libxr 1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
LibXR::LockQueue< Data > Class Template Reference

线程安全的队列实现,基于 FreeRTOS 消息队列 Thread-safe queue implementation based on FreeRTOS message queue More...

#include <lock_queue.hpp>

Collaboration diagram for LibXR::LockQueue< Data >:

Public Member Functions

 LockQueue (size_t length)
 构造函数,创建指定长度的队列 Constructor that creates a queue of specified length
 
 ~LockQueue ()
 析构函数,删除队列 Destructor that deletes the queue
 
ErrorCode Push (const Data &data)
 将数据推入队列(非阻塞) Pushes data into the queue (non-blocking)
 
ErrorCode Pop (Data &data, uint32_t timeout=UINT32_MAX)
 从队列弹出数据(阻塞) Pops data from the queue (blocking)
 
ErrorCode Pop (uint32_t timeout)
 从队列弹出数据(不关心数据值) Pops data from the queue without retrieving its value
 
ErrorCode Overwrite (const Data &data)
 覆盖队列中的数据 Overwrites the data in the queue
 
ErrorCode PushFromCallback (const Data &data, bool in_isr)
 从 ISR(中断服务例程)推入数据 Pushes data into the queue from an ISR (Interrupt Service Routine)
 
ErrorCode PopFromCallback (Data &data, bool in_isr)
 从 ISR(中断服务例程)弹出数据 Pops data from the queue in an ISR (Interrupt Service Routine)
 
ErrorCode PopFromCallback (bool in_isr)
 从 ISR(中断服务例程)弹出数据 Pops data from the queue in an ISR (Interrupt Service Routine)
 
ErrorCode OverwriteFromCallback (const Data &data, bool in_isr)
 从 ISR 覆盖队列中的数据 Overwrites the data in the queue from an ISR
 
ErrorCode Peek (Data &data)
 查看队列中的数据(非阻塞) Peeks at the data in the queue (non-blocking)
 
ErrorCode PeekFromCallback (Data &data, bool in_isr)
 从 ISR 查看队列中的数据 Peeks at the data in the queue from an ISR
 
void Reset ()
 重置队列,清空所有数据 Resets the queue, clearing all data
 
size_t Size ()
 获取队列中的数据项数量 Gets the number of items in the queue
 
size_t EmptySize ()
 获取队列剩余的可用空间 Gets the remaining available space in the queue
 
size_t SizeFromCallback (bool in_isr)
 从 ISR 获取队列大小 Gets the queue size from an ISR
 
size_t EmptySizeFromCallback (bool in_isr)
 从 ISR 获取队列剩余的可用空间 Gets the remaining available space in the queue from an ISR
 
 LockQueue (size_t length)
 构造函数,初始化队列 Constructor to initialize the queue
 
 ~LockQueue ()
 析构函数,释放资源 Destructor to release resources
 
ErrorCode Push (const Data &data)
 向队列中推送数据 Pushes data into the queue
 
ErrorCode Pop (Data &data, uint32_t timeout)
 从队列中弹出数据(带超时) Pops data from the queue with timeout
 
ErrorCode Pop ()
 无参数弹出数据 Pops data from the queue without storing it
 
ErrorCode PopFromCallback (bool in_isr)
 从回调函数中弹出数据 Pops data from the queue in a callback function
 
ErrorCode Pop (uint32_t timeout)
 带超时的弹出数据 Pops data from the queue with timeout
 
ErrorCode Overwrite (const Data &data)
 覆盖队列中的数据 Overwrites data in the queue
 
ErrorCode PushFromCallback (const Data &data, bool in_isr)
 从回调函数中推送数据 Pushes data into the queue from a callback function
 
ErrorCode PopFromCallback (Data &data, bool in_isr)
 从回调函数中弹出数据 Pops data from the queue in a callback function
 
ErrorCode OverwriteFromCallback (const Data &data, bool in_isr)
 从回调函数中覆盖数据 Overwrites data in the queue from a callback function
 
ErrorCode Peek (Data &item)
 查看队列中的数据(不弹出) Peeks at the data in the queue without popping it
 
ErrorCode PeekFromCallback (Data &item, bool in_isr)
 从回调函数中查看数据 Peeks at the data in the queue from a callback function
 
void Reset ()
 重置队列 Resets the queue
 
size_t Size ()
 获取队列中的数据项数量 Gets the number of items in the queue
 
size_t EmptySize ()
 获取队列的剩余容量 Gets the remaining capacity of the queue
 
size_t SizeFromCallback (bool in_isr)
 从回调函数中获取队列大小 Gets the queue size from a callback function
 
size_t EmptySizeFromCallback (bool in_isr)
 从回调函数中获取队列的剩余容量 Gets the remaining capacity of the queue from a callback function
 
 LockQueue (size_t length)
 构造函数,初始化队列 Constructor to initialize the queue
 
 ~LockQueue ()
 析构函数,释放资源 Destructor to release resources
 
ErrorCode Push (const Data &data)
 向队列中推送数据 Pushes data into the queue
 
ErrorCode Pop (Data &data, uint32_t timeout)
 从队列中弹出数据(带超时) Pops data from the queue with timeout
 
ErrorCode Pop ()
 无参数弹出数据 Pops data from the queue without storing it
 
ErrorCode PopFromCallback (bool in_isr)
 从回调函数中弹出数据 Pops data from the queue in a callback function
 
ErrorCode Pop (uint32_t timeout)
 带超时的弹出数据 Pops data from the queue with timeout
 
ErrorCode Overwrite (const Data &data)
 覆盖队列中的数据 Overwrites data in the queue
 
ErrorCode PushFromCallback (const Data &data, bool in_isr)
 从回调函数中推送数据 Pushes data into the queue from a callback function
 
ErrorCode PopFromCallback (Data &data, bool in_isr)
 从回调函数中弹出数据 Pops data from the queue in a callback function
 
ErrorCode OverwriteFromCallback (const Data &data, bool in_isr)
 从回调函数中覆盖数据 Overwrites data in the queue from a callback function
 
ErrorCode Peek (Data &item)
 查看队列中的数据(不弹出) Peeks at the data in the queue without popping it
 
ErrorCode PeekFromCallback (Data &item, bool in_isr)
 从回调函数中查看数据 Peeks at the data in the queue from a callback function
 
void Reset ()
 重置队列 Resets the queue
 
size_t Size ()
 获取队列中的数据项数量 Gets the number of items in the queue
 
size_t EmptySize ()
 获取队列的剩余容量 Gets the remaining capacity of the queue
 
size_t SizeFromCallback (bool in_isr)
 从回调函数中获取队列大小 Gets the queue size from a callback function
 
size_t EmptySizeFromCallback (bool in_isr)
 从回调函数中获取队列的剩余容量 Gets the remaining capacity of the queue from a callback function
 
 LockQueue (size_t length)
 构造函数,初始化队列 Constructor to initialize the queue
 
 ~LockQueue ()
 析构函数,释放资源 Destructor to release resources
 
ErrorCode Push (const Data &data)
 向队列中推送数据 Pushes data into the queue
 
ErrorCode Pop (Data &data, uint32_t timeout)
 从队列中弹出数据(带超时) Pops data from the queue with timeout
 
ErrorCode Pop ()
 无参数弹出数据 Pops data from the queue without storing it
 
ErrorCode PopFromCallback (bool in_isr)
 从回调函数中弹出数据 Pops data from the queue in a callback function
 
ErrorCode Pop (uint32_t timeout)
 带超时的弹出数据 Pops data from the queue with timeout
 
ErrorCode Overwrite (const Data &data)
 覆盖队列中的数据 Overwrites data in the queue
 
ErrorCode PushFromCallback (const Data &data, bool in_isr)
 从回调函数中推送数据 Pushes data into the queue from a callback function
 
ErrorCode PopFromCallback (Data &data, bool in_isr)
 从回调函数中弹出数据 Pops data from the queue in a callback function
 
ErrorCode OverwriteFromCallback (const Data &data, bool in_isr)
 从回调函数中覆盖数据 Overwrites data in the queue from a callback function
 
ErrorCode Peek (Data &item)
 查看队列中的数据(不弹出) Peeks at the data in the queue without popping it
 
ErrorCode PeekFromCallback (Data &item, bool in_isr)
 从回调函数中查看数据 Peeks at the data in the queue from a callback function
 
void Reset ()
 重置队列 Resets the queue
 
size_t Size ()
 获取队列中的数据项数量 Gets the number of items in the queue
 
size_t EmptySize ()
 获取队列的剩余容量 Gets the remaining capacity of the queue
 
size_t SizeFromCallback (bool in_isr)
 从回调函数中获取队列大小 Gets the queue size from a callback function
 
size_t EmptySizeFromCallback (bool in_isr)
 从回调函数中获取队列的剩余容量 Gets the remaining capacity of the queue from a callback function
 
 LockQueue (size_t length)
 构造函数,初始化队列 Constructor to initialize the queue
 
 ~LockQueue ()
 析构函数,释放资源 Destructor to release resources
 
ErrorCode Push (const Data &data)
 向队列中推送数据 Pushes data into the queue
 
ErrorCode Pop (Data &data, uint32_t timeout)
 从队列中弹出数据(带超时) Pops data from the queue with timeout
 
ErrorCode Pop ()
 无参数弹出数据 Pops data from the queue without storing it
 
ErrorCode PopFromCallback (bool in_isr)
 从回调函数中弹出数据 Pops data from the queue in a callback function
 
ErrorCode Pop (uint32_t timeout)
 带超时的弹出数据 Pops data from the queue with timeout
 
ErrorCode Overwrite (const Data &data)
 覆盖队列中的数据 Overwrites data in the queue
 
ErrorCode PushFromCallback (const Data &data, bool in_isr)
 从回调函数中推送数据 Pushes data into the queue from a callback function
 
ErrorCode PopFromCallback (Data &data, bool in_isr)
 从回调函数中弹出数据 Pops data from the queue in a callback function
 
ErrorCode OverwriteFromCallback (const Data &data, bool in_isr)
 从回调函数中覆盖数据 Overwrites data in the queue from a callback function
 
ErrorCode Peek (Data &item)
 查看队列中的数据(不弹出) Peeks at the data in the queue without popping it
 
ErrorCode PeekFromCallback (Data &item, bool in_isr)
 从回调函数中查看数据 Peeks at the data in the queue from a callback function
 
void Reset ()
 重置队列 Resets the queue
 
size_t Size ()
 获取队列中的数据项数量 Gets the number of items in the queue
 
size_t EmptySize ()
 获取队列的剩余容量 Gets the remaining capacity of the queue
 
size_t SizeFromCallback (bool in_isr)
 从回调函数中获取队列大小 Gets the queue size from a callback function
 
size_t EmptySizeFromCallback (bool in_isr)
 从回调函数中获取队列的剩余容量 Gets the remaining capacity of the queue from a callback function
 

Private Attributes

QueueHandle_t queue_handle_
 FreeRTOS 队列句柄 FreeRTOS queue handle.
 
const uint32_t LENGTH
 队列最大长度 Maximum queue length
 
Queue< Dataqueue_handle_
 底层队列对象 Underlying queue object
 
Mutex mutex_
 互斥锁 Mutex for thread safety
 
Semaphore semaphore_handle_
 信号量 Semaphore for synchronization
 

Detailed Description

template<typename Data>
class LibXR::LockQueue< Data >

线程安全的队列实现,基于 FreeRTOS 消息队列 Thread-safe queue implementation based on FreeRTOS message queue

线程安全的锁队列类,提供同步和异步操作支持 Thread-safe lock queue class with synchronous and asynchronous operation support

Template Parameters
Data队列存储的数据类型 The type of data stored in the queue

该类封装了 FreeRTOS 的 xQueue,提供线程安全的 Push、Pop、Peek 操作, 并支持中断服务例程(ISR)中的数据操作,确保任务间的数据同步与通信。

This class wraps FreeRTOS's xQueue, providing thread-safe Push, Pop, and Peek operations. It also supports operations in Interrupt Service Routines (ISR) to ensure safe data synchronization and communication between tasks.

Template Parameters
Data队列存储的数据类型 The type of data stored in the queue

Definition at line 25 of file lock_queue.hpp.

Constructor & Destructor Documentation

◆ LockQueue() [1/5]

template<typename Data >
LibXR::LockQueue< Data >::LockQueue ( size_t  length)
inline

构造函数,创建指定长度的队列 Constructor that creates a queue of specified length

Parameters
length队列的最大长度 The maximum length of the queue

Definition at line 33 of file lock_queue.hpp.

35 {
36 }
const uint32_t LENGTH
队列最大长度 Maximum queue length
QueueHandle_t queue_handle_
FreeRTOS 队列句柄 FreeRTOS queue handle.
constexpr auto min(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最小值

◆ ~LockQueue() [1/5]

template<typename Data >
LibXR::LockQueue< Data >::~LockQueue ( )
inline

析构函数,删除队列 Destructor that deletes the queue

Definition at line 42 of file lock_queue.hpp.

◆ LockQueue() [2/5]

template<typename Data >
LibXR::LockQueue< Data >::LockQueue ( size_t  length)
inline

构造函数,初始化队列 Constructor to initialize the queue

Parameters
length队列的最大长度 Maximum length of the queue

Definition at line 28 of file lock_queue.hpp.

◆ ~LockQueue() [2/5]

template<typename Data >
LibXR::LockQueue< Data >::~LockQueue ( )
inline

析构函数,释放资源 Destructor to release resources

Definition at line 34 of file lock_queue.hpp.

34{}

◆ LockQueue() [3/5]

template<typename Data >
LibXR::LockQueue< Data >::LockQueue ( size_t  length)
inline

构造函数,初始化队列 Constructor to initialize the queue

Parameters
length队列的最大长度 Maximum length of the queue

Definition at line 28 of file lock_queue.hpp.

◆ ~LockQueue() [3/5]

template<typename Data >
LibXR::LockQueue< Data >::~LockQueue ( )
inline

析构函数,释放资源 Destructor to release resources

Definition at line 34 of file lock_queue.hpp.

34{}

◆ LockQueue() [4/5]

template<typename Data >
LibXR::LockQueue< Data >::LockQueue ( size_t  length)
inline

构造函数,初始化队列 Constructor to initialize the queue

Parameters
length队列的最大长度 Maximum length of the queue

Definition at line 28 of file lock_queue.hpp.

◆ ~LockQueue() [4/5]

template<typename Data >
LibXR::LockQueue< Data >::~LockQueue ( )
inline

析构函数,释放资源 Destructor to release resources

Definition at line 34 of file lock_queue.hpp.

34{}

◆ LockQueue() [5/5]

template<typename Data >
LibXR::LockQueue< Data >::LockQueue ( size_t  length)
inline

构造函数,初始化队列 Constructor to initialize the queue

Parameters
length队列的最大长度 Maximum length of the queue

Definition at line 28 of file lock_queue.hpp.

◆ ~LockQueue() [5/5]

template<typename Data >
LibXR::LockQueue< Data >::~LockQueue ( )
inline

析构函数,释放资源 Destructor to release resources

Definition at line 34 of file lock_queue.hpp.

34{}

Member Function Documentation

◆ EmptySize() [1/5]

template<typename Data >
size_t LibXR::LockQueue< Data >::EmptySize ( )
inline

获取队列剩余的可用空间 Gets the remaining available space in the queue

Returns
可用空间大小 Available space size

Definition at line 297 of file lock_queue.hpp.

◆ EmptySize() [2/5]

template<typename Data >
size_t LibXR::LockQueue< Data >::EmptySize ( )
inline

获取队列的剩余容量 Gets the remaining capacity of the queue

Returns
剩余空间大小 Remaining space size

Definition at line 238 of file lock_queue.hpp.

239 {
240 mutex_.Lock();
241 auto ans = queue_handle_.EmptySize();
242 mutex_.Unlock();
243 return ans;
244 }
Mutex mutex_
互斥锁 Mutex for thread safety
ErrorCode Lock()
加锁,如果锁已被占用,则阻塞等待 (Lock the mutex, blocking if it is already locked).
Definition mutex.cpp:13
void Unlock()
解锁互斥锁 (Unlock the mutex).
Definition mutex.cpp:27

◆ EmptySize() [3/5]

template<typename Data >
size_t LibXR::LockQueue< Data >::EmptySize ( )
inline

获取队列的剩余容量 Gets the remaining capacity of the queue

Returns
剩余空间大小 Remaining space size

Definition at line 238 of file lock_queue.hpp.

239 {
240 mutex_.Lock();
241 auto ans = queue_handle_.EmptySize();
242 mutex_.Unlock();
243 return ans;
244 }

◆ EmptySize() [4/5]

template<typename Data >
size_t LibXR::LockQueue< Data >::EmptySize ( )
inline

获取队列的剩余容量 Gets the remaining capacity of the queue

Returns
剩余空间大小 Remaining space size

Definition at line 238 of file lock_queue.hpp.

239 {
240 mutex_.Lock();
241 auto ans = queue_handle_.EmptySize();
242 mutex_.Unlock();
243 return ans;
244 }

◆ EmptySize() [5/5]

template<typename Data >
size_t LibXR::LockQueue< Data >::EmptySize ( )
inline

获取队列的剩余容量 Gets the remaining capacity of the queue

Returns
剩余空间大小 Remaining space size

Definition at line 238 of file lock_queue.hpp.

239 {
240 mutex_.Lock();
241 auto ans = queue_handle_.EmptySize();
242 mutex_.Unlock();
243 return ans;
244 }

◆ EmptySizeFromCallback() [1/5]

template<typename Data >
size_t LibXR::LockQueue< Data >::EmptySizeFromCallback ( bool  in_isr)
inline

从 ISR 获取队列剩余的可用空间 Gets the remaining available space in the queue from an ISR

Parameters
in_isr是否在 ISR 环境中 Whether it is being called from an ISR
Returns
可用空间大小 Available space size

Definition at line 323 of file lock_queue.hpp.

324 {
325 if (!in_isr)
326 {
327 return EmptySize();
328 }
329 else
330 {
332 }
333 }
size_t EmptySize()
获取队列剩余的可用空间 Gets the remaining available space in the queue

◆ EmptySizeFromCallback() [2/5]

template<typename Data >
size_t LibXR::LockQueue< Data >::EmptySizeFromCallback ( bool  in_isr)
inline

从回调函数中获取队列的剩余容量 Gets the remaining capacity of the queue from a callback function

Parameters
in_isr是否在中断上下文中 Whether the function is called from an ISR
Returns
剩余空间大小 Remaining space size

Definition at line 264 of file lock_queue.hpp.

265 {
266 UNUSED(in_isr);
267 return EmptySize();
268 }

◆ EmptySizeFromCallback() [3/5]

template<typename Data >
size_t LibXR::LockQueue< Data >::EmptySizeFromCallback ( bool  in_isr)
inline

从回调函数中获取队列的剩余容量 Gets the remaining capacity of the queue from a callback function

Parameters
in_isr是否在中断上下文中 Whether the function is called from an ISR
Returns
剩余空间大小 Remaining space size

Definition at line 264 of file lock_queue.hpp.

265 {
266 UNUSED(in_isr);
267 return EmptySize();
268 }

◆ EmptySizeFromCallback() [4/5]

template<typename Data >
size_t LibXR::LockQueue< Data >::EmptySizeFromCallback ( bool  in_isr)
inline

从回调函数中获取队列的剩余容量 Gets the remaining capacity of the queue from a callback function

Parameters
in_isr是否在中断上下文中 Whether the function is called from an ISR
Returns
剩余空间大小 Remaining space size

Definition at line 264 of file lock_queue.hpp.

265 {
266 UNUSED(in_isr);
267 return EmptySize();
268 }

◆ EmptySizeFromCallback() [5/5]

template<typename Data >
size_t LibXR::LockQueue< Data >::EmptySizeFromCallback ( bool  in_isr)
inline

从回调函数中获取队列的剩余容量 Gets the remaining capacity of the queue from a callback function

Parameters
in_isr是否在中断上下文中 Whether the function is called from an ISR
Returns
剩余空间大小 Remaining space size

Definition at line 264 of file lock_queue.hpp.

265 {
266 UNUSED(in_isr);
267 return EmptySize();
268 }

◆ Overwrite() [1/5]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::Overwrite ( const Data data)
inline

覆盖队列中的数据 Overwrites the data in the queue

Parameters
data要写入的新数据 The new data to overwrite
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 109 of file lock_queue.hpp.

110 {
112 return Push(data);
113 }
ErrorCode Push(const Data &data)
将数据推入队列(非阻塞) Pushes data into the queue (non-blocking)

◆ Overwrite() [2/5]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::Overwrite ( const Data data)
inline

覆盖队列中的数据 Overwrites data in the queue

Parameters
data要覆盖写入的数据 The data to overwrite
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 128 of file lock_queue.hpp.

129 {
130 mutex_.Lock();
131 while (semaphore_handle_.Wait(0) != ErrorCode::OK)
132 {
133 }
134 auto ans = queue_handle_.Overwrite(data);
136 mutex_.Unlock();
137 return ans;
138 }
Semaphore semaphore_handle_
信号量 Semaphore for synchronization
void Post()
释放(增加)信号量 Releases (increments) the semaphore
Definition semaphore.cpp:13
ErrorCode Wait(uint32_t timeout=UINT32_MAX)
等待(减少)信号量 Waits (decrements) the semaphore
Definition semaphore.cpp:15

◆ Overwrite() [3/5]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::Overwrite ( const Data data)
inline

覆盖队列中的数据 Overwrites data in the queue

Parameters
data要覆盖写入的数据 The data to overwrite
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 128 of file lock_queue.hpp.

129 {
130 mutex_.Lock();
131 while (semaphore_handle_.Wait(0) != ErrorCode::OK)
132 {
133 }
134 auto ans = queue_handle_.Overwrite(data);
136 mutex_.Unlock();
137 return ans;
138 }

◆ Overwrite() [4/5]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::Overwrite ( const Data data)
inline

覆盖队列中的数据 Overwrites data in the queue

Parameters
data要覆盖写入的数据 The data to overwrite
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 128 of file lock_queue.hpp.

129 {
130 mutex_.Lock();
131 while (semaphore_handle_.Wait(0) != ErrorCode::OK)
132 {
133 }
134 auto ans = queue_handle_.Overwrite(data);
136 mutex_.Unlock();
137 return ans;
138 }

◆ Overwrite() [5/5]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::Overwrite ( const Data data)
inline

覆盖队列中的数据 Overwrites data in the queue

Parameters
data要覆盖写入的数据 The data to overwrite
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 128 of file lock_queue.hpp.

129 {
130 mutex_.Lock();
131 while (semaphore_handle_.Wait(0) != ErrorCode::OK)
132 {
133 }
134 auto ans = queue_handle_.Overwrite(data);
136 mutex_.Unlock();
137 return ans;
138 }

◆ OverwriteFromCallback() [1/5]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::OverwriteFromCallback ( const Data data,
bool  in_isr 
)
inline

从 ISR 覆盖队列中的数据 Overwrites the data in the queue from an ISR

Parameters
data要写入的新数据 The new data to overwrite
in_isr是否在 ISR 环境中 Whether it is being called from an ISR
Returns
操作结果 ErrorCode indicating success or failure

该方法在中断上下文中执行 Overwrite(),但目前 in_isr 参数未被使用。

This method performs Overwrite() in an interrupt context, but currently, the in_isr parameter is unused.

Definition at line 234 of file lock_queue.hpp.

235 {
236 UNUSED(in_isr);
237 return Overwrite(data);
238 }
ErrorCode Overwrite(const Data &data)
覆盖队列中的数据 Overwrites the data in the queue

◆ OverwriteFromCallback() [2/5]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::OverwriteFromCallback ( const Data data,
bool  in_isr 
)
inline

从回调函数中覆盖数据 Overwrites data in the queue from a callback function

Parameters
data要覆盖写入的数据 The data to overwrite
in_isr是否在中断上下文中 Whether the function is called from an ISR
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 173 of file lock_queue.hpp.

174 {
175 UNUSED(in_isr);
176 return Overwrite(data);
177 }

◆ OverwriteFromCallback() [3/5]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::OverwriteFromCallback ( const Data data,
bool  in_isr 
)
inline

从回调函数中覆盖数据 Overwrites data in the queue from a callback function

Parameters
data要覆盖写入的数据 The data to overwrite
in_isr是否在中断上下文中 Whether the function is called from an ISR
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 173 of file lock_queue.hpp.

174 {
175 UNUSED(in_isr);
176 return Overwrite(data);
177 }

◆ OverwriteFromCallback() [4/5]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::OverwriteFromCallback ( const Data data,
bool  in_isr 
)
inline

从回调函数中覆盖数据 Overwrites data in the queue from a callback function

Parameters
data要覆盖写入的数据 The data to overwrite
in_isr是否在中断上下文中 Whether the function is called from an ISR
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 173 of file lock_queue.hpp.

174 {
175 UNUSED(in_isr);
176 return Overwrite(data);
177 }

◆ OverwriteFromCallback() [5/5]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::OverwriteFromCallback ( const Data data,
bool  in_isr 
)
inline

从回调函数中覆盖数据 Overwrites data in the queue from a callback function

Parameters
data要覆盖写入的数据 The data to overwrite
in_isr是否在中断上下文中 Whether the function is called from an ISR
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 173 of file lock_queue.hpp.

174 {
175 UNUSED(in_isr);
176 return Overwrite(data);
177 }

◆ Peek() [1/5]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::Peek ( Data data)
inline

查看队列中的数据(非阻塞) Peeks at the data in the queue (non-blocking)

Parameters
data存储数据的变量 Variable to store the peeked data
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 246 of file lock_queue.hpp.

247 {
248 auto ans = xQueuePeek(queue_handle_, &data, 0);
249 if (ans == pdTRUE)
250 {
251 return ErrorCode::OK;
252 }
253 else
254 {
255 return ErrorCode::EMPTY;
256 }
257 }

◆ Peek() [2/5]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::Peek ( Data item)
inline

查看队列中的数据(不弹出) Peeks at the data in the queue without popping it

Parameters
item存储查看数据的变量 Variable to store the peeked data
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 185 of file lock_queue.hpp.

186 {
187 mutex_.Lock();
188 auto ans = queue_handle_.Peek(item);
189 mutex_.Unlock();
190 return ans;
191 }

◆ Peek() [3/5]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::Peek ( Data item)
inline

查看队列中的数据(不弹出) Peeks at the data in the queue without popping it

Parameters
item存储查看数据的变量 Variable to store the peeked data
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 185 of file lock_queue.hpp.

186 {
187 mutex_.Lock();
188 auto ans = queue_handle_.Peek(item);
189 mutex_.Unlock();
190 return ans;
191 }

◆ Peek() [4/5]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::Peek ( Data item)
inline

查看队列中的数据(不弹出) Peeks at the data in the queue without popping it

Parameters
item存储查看数据的变量 Variable to store the peeked data
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 185 of file lock_queue.hpp.

186 {
187 mutex_.Lock();
188 auto ans = queue_handle_.Peek(item);
189 mutex_.Unlock();
190 return ans;
191 }

◆ Peek() [5/5]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::Peek ( Data item)
inline

查看队列中的数据(不弹出) Peeks at the data in the queue without popping it

Parameters
item存储查看数据的变量 Variable to store the peeked data
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 185 of file lock_queue.hpp.

186 {
187 mutex_.Lock();
188 auto ans = queue_handle_.Peek(item);
189 mutex_.Unlock();
190 return ans;
191 }

◆ PeekFromCallback() [1/5]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::PeekFromCallback ( Data data,
bool  in_isr 
)
inline

从 ISR 查看队列中的数据 Peeks at the data in the queue from an ISR

Parameters
data存储数据的变量 Variable to store the peeked data
in_isr是否在 ISR 环境中 Whether it is being called from an ISR
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 266 of file lock_queue.hpp.

267 {
268 if (!in_isr)
269 {
270 return Peek(data);
271 }
272 else
273 {
274 return xQueuePeekFromISR(queue_handle_, &data) == pdTRUE ? ErrorCode::OK
275 : ErrorCode::EMPTY;
276 }
277 }
ErrorCode Peek(Data &data)
查看队列中的数据(非阻塞) Peeks at the data in the queue (non-blocking)

◆ PeekFromCallback() [2/5]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::PeekFromCallback ( Data item,
bool  in_isr 
)
inline

从回调函数中查看数据 Peeks at the data in the queue from a callback function

Parameters
item存储查看数据的变量 Variable to store the peeked data
in_isr是否在中断上下文中 Whether the function is called from an ISR
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 200 of file lock_queue.hpp.

201 {
202 UNUSED(in_isr);
203 return Peek(item);
204 }

◆ PeekFromCallback() [3/5]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::PeekFromCallback ( Data item,
bool  in_isr 
)
inline

从回调函数中查看数据 Peeks at the data in the queue from a callback function

Parameters
item存储查看数据的变量 Variable to store the peeked data
in_isr是否在中断上下文中 Whether the function is called from an ISR
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 200 of file lock_queue.hpp.

201 {
202 UNUSED(in_isr);
203 return Peek(item);
204 }

◆ PeekFromCallback() [4/5]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::PeekFromCallback ( Data item,
bool  in_isr 
)
inline

从回调函数中查看数据 Peeks at the data in the queue from a callback function

Parameters
item存储查看数据的变量 Variable to store the peeked data
in_isr是否在中断上下文中 Whether the function is called from an ISR
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 200 of file lock_queue.hpp.

201 {
202 UNUSED(in_isr);
203 return Peek(item);
204 }

◆ PeekFromCallback() [5/5]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::PeekFromCallback ( Data item,
bool  in_isr 
)
inline

从回调函数中查看数据 Peeks at the data in the queue from a callback function

Parameters
item存储查看数据的变量 Variable to store the peeked data
in_isr是否在中断上下文中 Whether the function is called from an ISR
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 200 of file lock_queue.hpp.

201 {
202 UNUSED(in_isr);
203 return Peek(item);
204 }

◆ Pop() [1/14]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::Pop ( )
inline

无参数弹出数据 Pops data from the queue without storing it

Returns
操作结果 ErrorCode indicating success or failure

Definition at line 81 of file lock_queue.hpp.

82 {
83 mutex_.Lock();
84 auto ans = queue_handle_.Pop();
85 mutex_.Unlock();
86 return ans;
87 }

◆ Pop() [2/14]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::Pop ( )
inline

无参数弹出数据 Pops data from the queue without storing it

Returns
操作结果 ErrorCode indicating success or failure

Definition at line 81 of file lock_queue.hpp.

82 {
83 mutex_.Lock();
84 auto ans = queue_handle_.Pop();
85 mutex_.Unlock();
86 return ans;
87 }

◆ Pop() [3/14]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::Pop ( )
inline

无参数弹出数据 Pops data from the queue without storing it

Returns
操作结果 ErrorCode indicating success or failure

Definition at line 81 of file lock_queue.hpp.

82 {
83 mutex_.Lock();
84 auto ans = queue_handle_.Pop();
85 mutex_.Unlock();
86 return ans;
87 }

◆ Pop() [4/14]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::Pop ( )
inline

无参数弹出数据 Pops data from the queue without storing it

Returns
操作结果 ErrorCode indicating success or failure

Definition at line 81 of file lock_queue.hpp.

82 {
83 mutex_.Lock();
84 auto ans = queue_handle_.Pop();
85 mutex_.Unlock();
86 return ans;
87 }

◆ Pop() [5/14]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::Pop ( Data data,
uint32_t  timeout 
)
inline

从队列中弹出数据(带超时) Pops data from the queue with timeout

Parameters
data存储弹出数据的变量 Variable to store the popped data
timeout超时时间(毫秒) Timeout in milliseconds
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 61 of file lock_queue.hpp.

62 {
63 if (semaphore_handle_.Wait(timeout) == ErrorCode::OK)
64 {
65 mutex_.Lock();
66 auto ans = queue_handle_.Pop(data);
67 mutex_.Unlock();
68 return ans;
69 }
70 else
71 {
72 return ErrorCode::TIMEOUT;
73 }
74 }

◆ Pop() [6/14]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::Pop ( Data data,
uint32_t  timeout 
)
inline

从队列中弹出数据(带超时) Pops data from the queue with timeout

Parameters
data存储弹出数据的变量 Variable to store the popped data
timeout超时时间(毫秒) Timeout in milliseconds
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 61 of file lock_queue.hpp.

62 {
63 if (semaphore_handle_.Wait(timeout) == ErrorCode::OK)
64 {
65 mutex_.Lock();
66 auto ans = queue_handle_.Pop(data);
67 mutex_.Unlock();
68 return ans;
69 }
70 else
71 {
72 return ErrorCode::TIMEOUT;
73 }
74 }

◆ Pop() [7/14]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::Pop ( Data data,
uint32_t  timeout 
)
inline

从队列中弹出数据(带超时) Pops data from the queue with timeout

Parameters
data存储弹出数据的变量 Variable to store the popped data
timeout超时时间(毫秒) Timeout in milliseconds
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 61 of file lock_queue.hpp.

62 {
63 if (semaphore_handle_.Wait(timeout) == ErrorCode::OK)
64 {
65 mutex_.Lock();
66 auto ans = queue_handle_.Pop(data);
67 mutex_.Unlock();
68 return ans;
69 }
70 else
71 {
72 return ErrorCode::TIMEOUT;
73 }
74 }

◆ Pop() [8/14]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::Pop ( Data data,
uint32_t  timeout 
)
inline

从队列中弹出数据(带超时) Pops data from the queue with timeout

Parameters
data存储弹出数据的变量 Variable to store the popped data
timeout超时时间(毫秒) Timeout in milliseconds
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 61 of file lock_queue.hpp.

62 {
63 if (semaphore_handle_.Wait(timeout) == ErrorCode::OK)
64 {
65 mutex_.Lock();
66 auto ans = queue_handle_.Pop(data);
67 mutex_.Unlock();
68 return ans;
69 }
70 else
71 {
72 return ErrorCode::TIMEOUT;
73 }
74 }

◆ Pop() [9/14]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::Pop ( Data data,
uint32_t  timeout = UINT32_MAX 
)
inline

从队列弹出数据(阻塞) Pops data from the queue (blocking)

Parameters
data存储弹出数据的变量 Variable to store the popped data
timeout超时时间(默认值:无限等待) Timeout period (default: infinite wait)
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 70 of file lock_queue.hpp.

71 {
72 auto ans = xQueueReceive(queue_handle_, &data, timeout);
73 if (ans == pdTRUE)
74 {
75 return ErrorCode::OK;
76 }
77 else
78 {
79 return ErrorCode::EMPTY;
80 }
81 }

◆ Pop() [10/14]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::Pop ( uint32_t  timeout)
inline

从队列弹出数据(不关心数据值) Pops data from the queue without retrieving its value

Parameters
timeout超时时间 Timeout period
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 89 of file lock_queue.hpp.

90 {
91 Data data;
92 auto ans = xQueueReceive(queue_handle_, &data, timeout);
93 if (ans == pdTRUE)
94 {
95 return ErrorCode::OK;
96 }
97 else
98 {
99 return ErrorCode::EMPTY;
100 }
101 }

◆ Pop() [11/14]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::Pop ( uint32_t  timeout)
inline

带超时的弹出数据 Pops data from the queue with timeout

Parameters
timeout超时时间(毫秒) Timeout in milliseconds
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 107 of file lock_queue.hpp.

108 {
109 if (semaphore_handle_.Wait(timeout) == ErrorCode::OK)
110 {
111 mutex_.Lock();
112 auto ans = queue_handle_.Pop();
113 mutex_.Unlock();
114 return ans;
115 }
116 else
117 {
118 return ErrorCode::TIMEOUT;
119 }
120 }

◆ Pop() [12/14]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::Pop ( uint32_t  timeout)
inline

带超时的弹出数据 Pops data from the queue with timeout

Parameters
timeout超时时间(毫秒) Timeout in milliseconds
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 107 of file lock_queue.hpp.

108 {
109 if (semaphore_handle_.Wait(timeout) == ErrorCode::OK)
110 {
111 mutex_.Lock();
112 auto ans = queue_handle_.Pop();
113 mutex_.Unlock();
114 return ans;
115 }
116 else
117 {
118 return ErrorCode::TIMEOUT;
119 }
120 }

◆ Pop() [13/14]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::Pop ( uint32_t  timeout)
inline

带超时的弹出数据 Pops data from the queue with timeout

Parameters
timeout超时时间(毫秒) Timeout in milliseconds
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 107 of file lock_queue.hpp.

108 {
109 if (semaphore_handle_.Wait(timeout) == ErrorCode::OK)
110 {
111 mutex_.Lock();
112 auto ans = queue_handle_.Pop();
113 mutex_.Unlock();
114 return ans;
115 }
116 else
117 {
118 return ErrorCode::TIMEOUT;
119 }
120 }

◆ Pop() [14/14]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::Pop ( uint32_t  timeout)
inline

带超时的弹出数据 Pops data from the queue with timeout

Parameters
timeout超时时间(毫秒) Timeout in milliseconds
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 107 of file lock_queue.hpp.

108 {
109 if (semaphore_handle_.Wait(timeout) == ErrorCode::OK)
110 {
111 mutex_.Lock();
112 auto ans = queue_handle_.Pop();
113 mutex_.Unlock();
114 return ans;
115 }
116 else
117 {
118 return ErrorCode::TIMEOUT;
119 }
120 }

◆ PopFromCallback() [1/10]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::PopFromCallback ( bool  in_isr)
inline

从 ISR(中断服务例程)弹出数据 Pops data from the queue in an ISR (Interrupt Service Routine)

Parameters
in_isr是否在 ISR 环境中 Whether it is being called from an ISR
Returns
操作结果 ErrorCode indicating success or failure

该方法在 ISR 环境中执行非阻塞数据弹出操作。如果 in_isrfalse,则调用标准 Pop() 方法。 若 in_isrtrue,则使用 xQueueReceiveFromISR() 进行队列操作,并在需要时触发任务调度 (portYIELD())。

This method performs a non-blocking data pop operation in an ISR environment. If in_isr is false, it calls the standard Pop() method. If in_isr is true, it uses xQueueReceiveFromISR() for queue operations and triggers a task switch (portYIELD()) if necessary.

Definition at line 195 of file lock_queue.hpp.

196 {
197 if (!in_isr)
198 {
199 return Pop(0);
200 }
201 else
202 {
203 Data data;
207 {
208 portYIELD(); // NOLINT
209 }
210 if (ans == pdTRUE)
211 {
212 return ErrorCode::OK;
213 }
214 else
215 {
216 return ErrorCode::EMPTY;
217 }
218 }
219 }
ErrorCode Pop()
无参数弹出数据 Pops data from the queue without storing it

◆ PopFromCallback() [2/10]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::PopFromCallback ( bool  in_isr)
inline

从回调函数中弹出数据 Pops data from the queue in a callback function

Parameters
in_isr是否在中断上下文中 Whether the function is called from an ISR
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 95 of file lock_queue.hpp.

96 {
97 UNUSED(in_isr);
98 return Pop();
99 }

◆ PopFromCallback() [3/10]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::PopFromCallback ( bool  in_isr)
inline

从回调函数中弹出数据 Pops data from the queue in a callback function

Parameters
in_isr是否在中断上下文中 Whether the function is called from an ISR
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 95 of file lock_queue.hpp.

96 {
97 UNUSED(in_isr);
98 return Pop();
99 }

◆ PopFromCallback() [4/10]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::PopFromCallback ( bool  in_isr)
inline

从回调函数中弹出数据 Pops data from the queue in a callback function

Parameters
in_isr是否在中断上下文中 Whether the function is called from an ISR
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 95 of file lock_queue.hpp.

96 {
97 UNUSED(in_isr);
98 return Pop();
99 }

◆ PopFromCallback() [5/10]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::PopFromCallback ( bool  in_isr)
inline

从回调函数中弹出数据 Pops data from the queue in a callback function

Parameters
in_isr是否在中断上下文中 Whether the function is called from an ISR
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 95 of file lock_queue.hpp.

96 {
97 UNUSED(in_isr);
98 return Pop();
99 }

◆ PopFromCallback() [6/10]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::PopFromCallback ( Data data,
bool  in_isr 
)
inline

从 ISR(中断服务例程)弹出数据 Pops data from the queue in an ISR (Interrupt Service Routine)

Parameters
data存储弹出数据的变量 Variable to store the popped data
in_isr是否在 ISR 环境中 Whether it is being called from an ISR
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 154 of file lock_queue.hpp.

155 {
156 if (!in_isr)
157 {
158 return Pop(data, 0);
159 }
160 else
161 {
165 {
166 portYIELD(); // NOLINT
167 }
168 if (ans == pdTRUE)
169 {
170 return ErrorCode::OK;
171 }
172 else
173 {
174 return ErrorCode::EMPTY;
175 }
176 }
177 }

◆ PopFromCallback() [7/10]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::PopFromCallback ( Data data,
bool  in_isr 
)
inline

从回调函数中弹出数据 Pops data from the queue in a callback function

Parameters
data存储弹出数据的变量 Variable to store the popped data
in_isr是否在中断上下文中 Whether the function is called from an ISR
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 160 of file lock_queue.hpp.

161 {
162 UNUSED(in_isr);
163 return Pop(data, 0);
164 }

◆ PopFromCallback() [8/10]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::PopFromCallback ( Data data,
bool  in_isr 
)
inline

从回调函数中弹出数据 Pops data from the queue in a callback function

Parameters
data存储弹出数据的变量 Variable to store the popped data
in_isr是否在中断上下文中 Whether the function is called from an ISR
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 160 of file lock_queue.hpp.

161 {
162 UNUSED(in_isr);
163 return Pop(data, 0);
164 }

◆ PopFromCallback() [9/10]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::PopFromCallback ( Data data,
bool  in_isr 
)
inline

从回调函数中弹出数据 Pops data from the queue in a callback function

Parameters
data存储弹出数据的变量 Variable to store the popped data
in_isr是否在中断上下文中 Whether the function is called from an ISR
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 160 of file lock_queue.hpp.

161 {
162 UNUSED(in_isr);
163 return Pop(data, 0);
164 }

◆ PopFromCallback() [10/10]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::PopFromCallback ( Data data,
bool  in_isr 
)
inline

从回调函数中弹出数据 Pops data from the queue in a callback function

Parameters
data存储弹出数据的变量 Variable to store the popped data
in_isr是否在中断上下文中 Whether the function is called from an ISR
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 160 of file lock_queue.hpp.

161 {
162 UNUSED(in_isr);
163 return Pop(data, 0);
164 }

◆ Push() [1/5]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::Push ( const Data data)
inline

将数据推入队列(非阻塞) Pushes data into the queue (non-blocking)

Parameters
data需要推入的数据 The data to be pushed
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 50 of file lock_queue.hpp.

51 {
52 auto ans = xQueueSend(queue_handle_, &data, 0);
53 if (ans == pdTRUE)
54 {
55 return ErrorCode::OK;
56 }
57 else
58 {
59 return ErrorCode::FULL;
60 }
61 }

◆ Push() [2/5]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::Push ( const Data data)
inline

向队列中推送数据 Pushes data into the queue

Parameters
data要推送的数据 The data to be pushed
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 42 of file lock_queue.hpp.

43 {
44 mutex_.Lock();
45 auto ans = queue_handle_.Push(data);
46 if (ans == ErrorCode::OK)
47 {
49 }
50 mutex_.Unlock();
51 return ans;
52 }

◆ Push() [3/5]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::Push ( const Data data)
inline

向队列中推送数据 Pushes data into the queue

Parameters
data要推送的数据 The data to be pushed
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 42 of file lock_queue.hpp.

43 {
44 mutex_.Lock();
45 auto ans = queue_handle_.Push(data);
46 if (ans == ErrorCode::OK)
47 {
49 }
50 mutex_.Unlock();
51 return ans;
52 }

◆ Push() [4/5]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::Push ( const Data data)
inline

向队列中推送数据 Pushes data into the queue

Parameters
data要推送的数据 The data to be pushed
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 42 of file lock_queue.hpp.

43 {
44 mutex_.Lock();
45 auto ans = queue_handle_.Push(data);
46 if (ans == ErrorCode::OK)
47 {
49 }
50 mutex_.Unlock();
51 return ans;
52 }

◆ Push() [5/5]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::Push ( const Data data)
inline

向队列中推送数据 Pushes data into the queue

Parameters
data要推送的数据 The data to be pushed
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 42 of file lock_queue.hpp.

43 {
44 mutex_.Lock();
45 auto ans = queue_handle_.Push(data);
46 if (ans == ErrorCode::OK)
47 {
49 }
50 mutex_.Unlock();
51 return ans;
52 }

◆ PushFromCallback() [1/5]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::PushFromCallback ( const Data data,
bool  in_isr 
)
inline

从 ISR(中断服务例程)推入数据 Pushes data into the queue from an ISR (Interrupt Service Routine)

Parameters
data需要推入的数据 The data to be pushed
in_isr是否在 ISR 环境中 Whether it is being called from an ISR
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 122 of file lock_queue.hpp.

123 {
124 if (!in_isr)
125 {
126 return Push(data) == pdTRUE ? ErrorCode::OK : ErrorCode::FULL;
127 }
128 else
129 {
133 {
134 portYIELD(); // NOLINT
135 }
136 if (ans == pdTRUE)
137 {
138 return ErrorCode::OK;
139 }
140 else
141 {
142 return ErrorCode::FULL;
143 }
144 }
145 }

◆ PushFromCallback() [2/5]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::PushFromCallback ( const Data data,
bool  in_isr 
)
inline

从回调函数中推送数据 Pushes data into the queue from a callback function

Parameters
data要推送的数据 The data to be pushed
in_isr是否在中断上下文中 Whether the function is called from an ISR
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 147 of file lock_queue.hpp.

148 {
149 UNUSED(in_isr);
150 return Push(data);
151 }

◆ PushFromCallback() [3/5]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::PushFromCallback ( const Data data,
bool  in_isr 
)
inline

从回调函数中推送数据 Pushes data into the queue from a callback function

Parameters
data要推送的数据 The data to be pushed
in_isr是否在中断上下文中 Whether the function is called from an ISR
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 147 of file lock_queue.hpp.

148 {
149 UNUSED(in_isr);
150 return Push(data);
151 }

◆ PushFromCallback() [4/5]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::PushFromCallback ( const Data data,
bool  in_isr 
)
inline

从回调函数中推送数据 Pushes data into the queue from a callback function

Parameters
data要推送的数据 The data to be pushed
in_isr是否在中断上下文中 Whether the function is called from an ISR
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 147 of file lock_queue.hpp.

148 {
149 UNUSED(in_isr);
150 return Push(data);
151 }

◆ PushFromCallback() [5/5]

template<typename Data >
ErrorCode LibXR::LockQueue< Data >::PushFromCallback ( const Data data,
bool  in_isr 
)
inline

从回调函数中推送数据 Pushes data into the queue from a callback function

Parameters
data要推送的数据 The data to be pushed
in_isr是否在中断上下文中 Whether the function is called from an ISR
Returns
操作结果 ErrorCode indicating success or failure

Definition at line 147 of file lock_queue.hpp.

148 {
149 UNUSED(in_isr);
150 return Push(data);
151 }

◆ Reset() [1/5]

template<typename Data >
void LibXR::LockQueue< Data >::Reset ( )
inline

重置队列,清空所有数据 Resets the queue, clearing all data

Definition at line 283 of file lock_queue.hpp.

◆ Reset() [2/5]

template<typename Data >
void LibXR::LockQueue< Data >::Reset ( )
inline

重置队列 Resets the queue

Definition at line 210 of file lock_queue.hpp.

211 {
212 mutex_.Lock();
213 while (semaphore_handle_.Wait(0) == ErrorCode::OK)
214 {
215 };
216 queue_handle_.Reset();
217 mutex_.Unlock();
218 }

◆ Reset() [3/5]

template<typename Data >
void LibXR::LockQueue< Data >::Reset ( )
inline

重置队列 Resets the queue

Definition at line 210 of file lock_queue.hpp.

211 {
212 mutex_.Lock();
213 while (semaphore_handle_.Wait(0) == ErrorCode::OK)
214 {
215 };
216 queue_handle_.Reset();
217 mutex_.Unlock();
218 }

◆ Reset() [4/5]

template<typename Data >
void LibXR::LockQueue< Data >::Reset ( )
inline

重置队列 Resets the queue

Definition at line 210 of file lock_queue.hpp.

211 {
212 mutex_.Lock();
213 while (semaphore_handle_.Wait(0) == ErrorCode::OK)
214 {
215 };
216 queue_handle_.Reset();
217 mutex_.Unlock();
218 }

◆ Reset() [5/5]

template<typename Data >
void LibXR::LockQueue< Data >::Reset ( )
inline

重置队列 Resets the queue

Definition at line 210 of file lock_queue.hpp.

211 {
212 mutex_.Lock();
213 while (semaphore_handle_.Wait(0) == ErrorCode::OK)
214 {
215 };
216 queue_handle_.Reset();
217 mutex_.Unlock();
218 }

◆ Size() [1/5]

template<typename Data >
size_t LibXR::LockQueue< Data >::Size ( )
inline

获取队列中的数据项数量 Gets the number of items in the queue

Returns
当前队列大小 Current queue size

Definition at line 290 of file lock_queue.hpp.

◆ Size() [2/5]

template<typename Data >
size_t LibXR::LockQueue< Data >::Size ( )
inline

获取队列中的数据项数量 Gets the number of items in the queue

Returns
当前队列大小 Current queue size

Definition at line 225 of file lock_queue.hpp.

226 {
227 mutex_.Lock();
228 auto ans = queue_handle_.Size();
229 mutex_.Unlock();
230 return ans;
231 }

◆ Size() [3/5]

template<typename Data >
size_t LibXR::LockQueue< Data >::Size ( )
inline

获取队列中的数据项数量 Gets the number of items in the queue

Returns
当前队列大小 Current queue size

Definition at line 225 of file lock_queue.hpp.

226 {
227 mutex_.Lock();
228 auto ans = queue_handle_.Size();
229 mutex_.Unlock();
230 return ans;
231 }

◆ Size() [4/5]

template<typename Data >
size_t LibXR::LockQueue< Data >::Size ( )
inline

获取队列中的数据项数量 Gets the number of items in the queue

Returns
当前队列大小 Current queue size

Definition at line 225 of file lock_queue.hpp.

226 {
227 mutex_.Lock();
228 auto ans = queue_handle_.Size();
229 mutex_.Unlock();
230 return ans;
231 }

◆ Size() [5/5]

template<typename Data >
size_t LibXR::LockQueue< Data >::Size ( )
inline

获取队列中的数据项数量 Gets the number of items in the queue

Returns
当前队列大小 Current queue size

Definition at line 225 of file lock_queue.hpp.

226 {
227 mutex_.Lock();
228 auto ans = queue_handle_.Size();
229 mutex_.Unlock();
230 return ans;
231 }

◆ SizeFromCallback() [1/5]

template<typename Data >
size_t LibXR::LockQueue< Data >::SizeFromCallback ( bool  in_isr)
inline

从 ISR 获取队列大小 Gets the queue size from an ISR

Parameters
in_isr是否在 ISR 环境中 Whether it is being called from an ISR
Returns
当前队列大小 Current queue size

Definition at line 305 of file lock_queue.hpp.

306 {
307 if (!in_isr)
308 {
309 return Size();
310 }
311 else
312 {
314 }
315 }
size_t Size()
获取队列中的数据项数量 Gets the number of items in the queue

◆ SizeFromCallback() [2/5]

template<typename Data >
size_t LibXR::LockQueue< Data >::SizeFromCallback ( bool  in_isr)
inline

从回调函数中获取队列大小 Gets the queue size from a callback function

Parameters
in_isr是否在中断上下文中 Whether the function is called from an ISR
Returns
当前队列大小 Current queue size

Definition at line 252 of file lock_queue.hpp.

253 {
254 UNUSED(in_isr);
255 return Size();
256 }

◆ SizeFromCallback() [3/5]

template<typename Data >
size_t LibXR::LockQueue< Data >::SizeFromCallback ( bool  in_isr)
inline

从回调函数中获取队列大小 Gets the queue size from a callback function

Parameters
in_isr是否在中断上下文中 Whether the function is called from an ISR
Returns
当前队列大小 Current queue size

Definition at line 252 of file lock_queue.hpp.

253 {
254 UNUSED(in_isr);
255 return Size();
256 }

◆ SizeFromCallback() [4/5]

template<typename Data >
size_t LibXR::LockQueue< Data >::SizeFromCallback ( bool  in_isr)
inline

从回调函数中获取队列大小 Gets the queue size from a callback function

Parameters
in_isr是否在中断上下文中 Whether the function is called from an ISR
Returns
当前队列大小 Current queue size

Definition at line 252 of file lock_queue.hpp.

253 {
254 UNUSED(in_isr);
255 return Size();
256 }

◆ SizeFromCallback() [5/5]

template<typename Data >
size_t LibXR::LockQueue< Data >::SizeFromCallback ( bool  in_isr)
inline

从回调函数中获取队列大小 Gets the queue size from a callback function

Parameters
in_isr是否在中断上下文中 Whether the function is called from an ISR
Returns
当前队列大小 Current queue size

Definition at line 252 of file lock_queue.hpp.

253 {
254 UNUSED(in_isr);
255 return Size();
256 }

Field Documentation

◆ LENGTH

template<typename Data >
const uint32_t LibXR::LockQueue< Data >::LENGTH
private

队列最大长度 Maximum queue length

Definition at line 337 of file lock_queue.hpp.

◆ mutex_

template<typename Data >
Mutex LibXR::LockQueue< Data >::mutex_
private

互斥锁 Mutex for thread safety

Definition at line 272 of file lock_queue.hpp.

◆ queue_handle_ [1/2]

template<typename Data >
Queue< Data > LibXR::LockQueue< Data >::queue_handle_
private

FreeRTOS 队列句柄 FreeRTOS queue handle.

底层队列对象 Underlying queue object

Definition at line 336 of file lock_queue.hpp.

◆ queue_handle_ [2/2]

template<typename Data >
Queue<Data> LibXR::LockQueue< Data >::queue_handle_
private

底层队列对象 Underlying queue object

Definition at line 271 of file lock_queue.hpp.

◆ semaphore_handle_

template<typename Data >
Semaphore LibXR::LockQueue< Data >::semaphore_handle_
private

信号量 Semaphore for synchronization

Definition at line 273 of file lock_queue.hpp.


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