3#include "libxr_def.hpp"
14 return ErrorCode::BUSY;
Status status_
当前异步任务状态。 The current status of the asynchronous task.
@ BUSY
任务正在执行中。 Task is currently running.
Thread thread_handle_
处理异步任务的线程。 Thread handling asynchronous tasks.
ASync(size_t stack_depth, Thread::Priority priority)
构造 ASync 对象并初始化任务线程。 Constructs an ASync object and initializes the task thread.
Semaphore sem_
控制任务执行的信号量。 Semaphore controlling task execution.
static void ThreadFun(ASync *async)
任务线程函数,等待信号量并执行任务。 Task thread function that waits for a semaphore and executes the assigned job.
ErrorCode AssignJob(Callback job)
分配一个异步任务并准备执行。 Assigns an asynchronous job and prepares for execution.
Callback job_
存储分配的异步任务回调。 Stores the assigned asynchronous job callback.
提供一个通用的回调包装,支持动态参数传递。 Provides a generic callback wrapper, supporting dynamic argument passing.
void Post()
释放(增加)信号量 Releases (increments) the semaphore
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
LibXR Color Control Library / LibXR终端颜色控制库
constexpr auto min(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最小值