9#ifdef LIBXR_NOT_SUPPORT_MUTI_THREAD
15 if (async->pending_.exchange(0U, std::memory_order_acquire) != 0U)
34 std::memory_order_relaxed))
40#ifdef LIBXR_NOT_SUPPORT_MUTI_THREAD
42 pending_.store(1U, std::memory_order_release);
51 job_.Run(
false,
this);
单任务异步执行器 / Single-job asynchronous executor.
std::atomic< Status > status_
当前异步任务状态
Job job_
存储分配的异步任务回调 / Stores the assigned asynchronous job callback.
ErrorCode AssignJob(Job job)
提交任务 / Submit a job.
Thread thread_handle_
处理异步任务的线程 / Thread handling asynchronous tasks.
ASync(size_t stack_depth, Thread::Priority priority)
构造 ASync 并初始化线程或软件 Timer。 Constructs an ASync and initializes its worker or software Timer.
Semaphore sem_
控制任务执行的信号量 / Semaphore controlling task execution.
static void ThreadFun(ASync *async)
任务线程函数,等待信号量并执行任务。 Task thread function that waits for a semaphore and executes the assigned job.
Status
异步任务的状态枚举。 Enumeration of asynchronous task statuses.
@ DONE
任务已完成,尚未取走状态 / Completed, awaiting acknowledgment.
@ READY
任务已准备就绪 / Task is ready.
@ BUSY
任务已接收或正在执行 / Job accepted or running.
ErrorCode AssignJobFromCallback(Job job, bool in_isr)
从回调上下文提交任务 / Submit a job from callback context.
void PostFromCallback(bool in_isr)
从中断回调中释放(增加)信号量 Releases (increments) the semaphore from an ISR (Interrupt Service Routine)
ErrorCode Wait(uint32_t timeout=UINT32_MAX)
等待(减少)信号量 Waits (decrements) 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
static TimerHandle CreateTask(void(*fun)(ArgType), ArgType arg, uint32_t cycle)
创建定时任务 Creates a periodic task
static void Start(TimerHandle handle)
启动定时任务 Starts a periodic task
static void Add(TimerHandle handle)
添加定时任务 Adds a periodic task
LibXR 命名空间 / LibXR namespace.
ErrorCode
定义错误码枚举 / Defines an enumeration for error codes
@ OK
操作成功 / Operation successful