5#include "libxr_def.hpp"
8#include "semaphore.hpp"
19template <
typename Data>
42 ErrorCode
Push(
const Data &data)
46 if (ans == ErrorCode::OK)
61 ErrorCode
Pop(Data &data, uint32_t timeout)
72 return ErrorCode::TIMEOUT;
95 ErrorCode
Pop(uint32_t timeout)
106 return ErrorCode::TIMEOUT;
线程安全的锁队列类,提供同步和异步操作支持 Thread-safe lock queue class with synchronous and asynchronous operation suppor...
ErrorCode Pop(Data &data, uint32_t timeout)
从队列中弹出数据(带超时) Pops data from the queue with timeout
~LockQueue()
析构函数,释放资源 Destructor to release resources
size_t Size()
获取队列中的数据项数量 Gets the number of items in the queue
ErrorCode Pop()
无参数弹出数据 Pops data from the queue without storing it
Queue< Data > queue_handle_
底层队列对象 Underlying queue object
ErrorCode Push(const Data &data)
向队列中推送数据 Pushes data into the queue
size_t EmptySize()
获取队列的剩余容量 Gets the remaining capacity of the queue
Mutex mutex_
互斥锁 Mutex for thread safety
Semaphore semaphore_handle_
信号量 Semaphore for synchronization
ErrorCode PushFromCallback(const Data &data, bool in_isr)
从回调函数中推送数据 Pushes data into the queue from a callback function
ErrorCode Pop(uint32_t timeout)
带超时的弹出数据 Pops data from the queue with timeout
LockQueue(size_t length)
构造函数,初始化队列 Constructor to initialize the queue
互斥锁类,提供线程同步机制 (Mutex class providing thread synchronization mechanisms).
ErrorCode Lock()
加锁,如果锁已被占用,则阻塞等待 (Lock the mutex, blocking if it is already locked).
void Unlock()
解锁互斥锁 (Unlock the mutex).
基于 BaseQueue 的泛型队列模板类 (Generic queue template class based on BaseQueue).
信号量类,实现线程同步机制 Semaphore class implementing thread synchronization
void Post()
释放(增加)信号量 Releases (increments) the semaphore
ErrorCode Wait(uint32_t timeout=UINT32_MAX)
等待(减少)信号量 Waits (decrements) the semaphore