5#include "libxr_def.hpp"
68 template <
typename ArgType>
84 data->ctrl_block.
data_.handle = data;
85 data->ctrl_block.data_.fun_ = [](
void *arg)
87 Data *data =
reinterpret_cast<Data *
>(arg);
90 data->ctrl_block.data_.count_ = 0;
91 data->ctrl_block.data_.cycle_ = cycle;
92 data->ctrl_block.data_.enable_ =
false;
94 return &data->ctrl_block;
119 handle->
data_.cycle_ = cycle;
160 ASSERT(handle->
next_);
171 ASSERT(!handle->
next_);
176#ifdef LIBXR_NOT_SUPPORT_MUTI_THREAD
203#ifndef LIBXR_NOT_SUPPORT_MUTI_THREAD
215 return ErrorCode::OK;
226 return ErrorCode::OK;
BaseNode * next_
指向下一个节点的指针。 Pointer to the next node.
数据节点模板,继承自 BaseNode,用于存储具体数据类型。 Template data node that inherits from BaseNode to store specific data...
Data data_
存储的数据。 The stored data.
链表实现,用于存储和管理数据节点。 A linked list implementation for storing and managing data nodes.
void Add(BaseNode &data)
向链表添加一个节点。 Adds a node to the linked list.
ErrorCode Delete(BaseNode &data) noexcept
从链表中删除指定的节点。 Deletes a specified node from the linked list.
ErrorCode Foreach(Func func)
遍历链表中的每个节点,并应用回调函数。 Iterates over each node in the list and applies a callback function.
线程管理类,封装 FreeRTOS 任务创建和调度 Thread management class encapsulating FreeRTOS task creation and scheduling
static uint32_t GetTime()
获取当前系统时间(毫秒) Gets the current system time in milliseconds
Priority
线程优先级枚举 Enumeration for thread priorities
void Create(ArgType arg, void(*function)(ArgType arg), const char *name, size_t stack_depth, Thread::Priority priority)
创建新线程 Creates a new thread
static void SleepUntil(TimestampMS &last_waskup_time, uint32_t time_to_sleep)
让线程休眠直到指定时间点 Puts the thread to sleep until a specified time
控制块类,存储任务信息 Control block class for storing task information
void Run()
运行定时任务 Runs the scheduled task
uint32_t cycle_
任务周期(单位:毫秒) Task cycle (unit: milliseconds)
void * handle
任务句柄 Handle to the task
uint32_t count_
计数器 Counter
bool enable_
任务是否启用 Flag indicating whether the task is enabled
void(* fun_)(void *)
任务执行函数 Function pointer to the task
定时器类,实现周期性任务调度 Timer class for scheduling periodic tasks
static void Refresh()
刷新定时任务状态 Refreshes the state of periodic tasks
static Thread thread_handle_
定时器管理线程 Timer management thread
static uint32_t stack_depth_
线程栈深度 Thread stack depth
static void Remove(TimerHandle handle)
删除定时任务 Removes a periodic task
static LibXR::List * list_
定时任务列表 List of registered tasks
static LibXR::Thread::Priority priority_
线程优先级 Thread priority
static void Start(TimerHandle handle)
启动定时任务 Starts a periodic task
static TimerHandle CreateTask(void(*fun)(ArgType), ArgType arg, uint32_t cycle)
创建定时任务 Creates a periodic task
static void RefreshThreadFunction(void *)
定时器管理线程函数 Timer management thread function
LibXR::List::Node< ControlBlock > * TimerHandle
定时器任务句柄 Timer task handle
static void RefreshTimerInIdle()
在空闲时刷新定时器 Refreshes the timer during idle time
static void Stop(TimerHandle handle)
停止定时任务 Stops a periodic task
static void SetCycle(TimerHandle handle, uint32_t cycle)
设置定时任务的周期 Sets the cycle of a periodic task
static void Add(TimerHandle handle)
添加定时任务 Adds a periodic task
表示毫秒级时间戳的类。Class representing a timestamp in milliseconds.
LibXR Color Control Library / LibXR终端颜色控制库
constexpr auto min(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最小值