5#include "libxr_def.hpp"
8#include "semaphore.hpp"
19template <
typename Data>
46 if (
ans == ErrorCode::OK)
72 return ErrorCode::TIMEOUT;
118 return ErrorCode::TIMEOUT;
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
ErrorCode Peek(Data &item)
查看队列中的数据(不弹出) Peeks at the data in the queue without popping it
ErrorCode Push(const Data &data)
向队列中推送数据 Pushes data into the queue
void Reset()
重置队列 Resets the queue
ErrorCode Peek(Data &data)
查看队列中的数据(非阻塞) Peeks at the data in the queue (non-blocking)
ErrorCode PopFromCallback(Data &data, bool in_isr)
从回调函数中弹出数据 Pops data from the queue in a callback function
size_t SizeFromCallback(bool in_isr)
从回调函数中获取队列大小 Gets the queue size from a callback function
size_t EmptySize()
获取队列的剩余容量 Gets the remaining capacity of the queue
Mutex mutex_
互斥锁 Mutex for thread safety
ErrorCode OverwriteFromCallback(const Data &data, bool in_isr)
从回调函数中覆盖数据 Overwrites data in the queue from a callback function
Semaphore semaphore_handle_
信号量 Semaphore for synchronization
ErrorCode PopFromCallback(bool in_isr)
从回调函数中弹出数据 Pops data from the queue in a callback function
ErrorCode PeekFromCallback(Data &item, bool in_isr)
从回调函数中查看数据 Peeks at the data in the queue from a callback function
QueueHandle_t queue_handle_
FreeRTOS 队列句柄 FreeRTOS queue handle.
size_t EmptySizeFromCallback(bool in_isr)
从回调函数中获取队列的剩余容量 Gets the remaining capacity of the queue from a callback function
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
ErrorCode Overwrite(const Data &data)
覆盖队列中的数据 Overwrites data in 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
LibXR Color Control Library / LibXR终端颜色控制库
constexpr auto min(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最小值