|
libxr
Embedded C++ framework for bare-metal, RTOS and Linux
|
操作的完成通知描述符 / Completion notification descriptor for an operation. More...
#include <operation.hpp>
Public Types | |
| enum class | OperationType : uint8_t { CALLBACK , BLOCK , POLLING , NONE } |
| 完成通知方式 / Completion notification mode. More... | |
| enum class | OperationPollingStatus : uint32_t { READY , RUNNING , DONE , ERROR } |
| using | Callback = LibXR::Callback<Args> |
Public Member Functions | |
| Operation () | |
| 构造无完成通知的操作 / Construct an operation without notification. | |
| Operation (Semaphore &sem, uint32_t timeout=UINT32_MAX) | |
| 构造阻塞操作 / Construct a blocking operation. | |
| Operation (Callback &callback) | |
| 构造回调操作 / Construct a callback operation. | |
| Operation (std::atomic< OperationPollingStatus > &status) | |
| 构造轮询操作 / Construct a polling operation. | |
| Operation (const Operation &)=default | |
| 复制通知描述符,共用通知对象 / Copy the descriptor, sharing notification targets. | |
| Operation (Operation &&) noexcept=default | |
| 移动描述符,源描述符保持不变 / Move the descriptor without clearing the source. | |
| Operation & | operator= (const Operation &)=default |
| 复制通知描述符 / Copy the notification descriptor. | |
| Operation & | operator= (Operation &&) noexcept=default |
| 移动通知描述符 / Move the notification descriptor. | |
| template<typename Status > | |
| void | UpdateStatus (bool in_isr, Status &&status) |
| 按通知方式报告完成结果 / Report completion using the selected mode. | |
| void | MarkAsRunning () |
| 标记轮询操作正在执行 / Mark a polling operation as running. | |
Public Attributes | ||
| union { | ||
| Callback * callback | ||
| 借用的回调对象 / Borrowed callback. More... | ||
| struct { | ||
| Semaphore * sem | ||
| 借用的信号量 / Borrowed semaphore. More... | ||
| uint32_t timeout | ||
| 等待超时值 / Wait timeout. More... | ||
| } sem_info | ||
| std::atomic< OperationPollingStatus > * status | ||
| 借用的轮询状态 / Borrowed polling status. More... | ||
| } | data | |
| 完成通知对象,由 type 选择有效成员 / Notification target selected by type. | ||
| OperationType | type | |
| 当前通知方式 / Current notification mode. | ||
操作的完成通知描述符 / Completion notification descriptor for an operation.
| Args | 回调参数类型 / Callback argument type. |
Definition at line 24 of file operation.hpp.
| using LibXR::Operation< Args >::Callback = LibXR::Callback<Args> |
Definition at line 27 of file operation.hpp.
|
strong |
轮询操作状态;保持字宽,避免 M0 引入 byte-atomic runtime ABI / Polling status; keep it word-sized to avoid byte-atomic runtime ABI on M0.
| Enumerator | |
|---|---|
| READY | 尚未开始 / Not started. |
| RUNNING | 正在执行 / In progress. |
| DONE | 成功完成 / Completed successfully. |
| ERROR | 错误结束 / Completed with an error. |
Definition at line 40 of file operation.hpp.
|
strong |
完成通知方式 / Completion notification mode.
| Enumerator | |
|---|---|
| CALLBACK | 执行回调 / Invoke a callback. |
| BLOCK | 信号量等待 / Wait with a semaphore. |
| POLLING | 查询原子状态 / Poll an atomic status. |
| NONE | 无完成通知 / No completion notification. |
Definition at line 30 of file operation.hpp.
|
inline |
构造无完成通知的操作 / Construct an operation without notification.
Definition at line 49 of file operation.hpp.
|
inline |
构造阻塞操作 / Construct a blocking operation.
| sem | 等待完成的信号量 / Semaphore for completion waiting. |
| timeout | 传给 Semaphore::Wait 的超时值,默认 UINT32_MAX。 Timeout passed to Semaphore::Wait; defaults to UINT32_MAX. |
Definition at line 59 of file operation.hpp.
|
inline |
构造回调操作 / Construct a callback operation.
| callback | 借用的完成回调 / Borrowed completion callback. |
Definition at line 68 of file operation.hpp.
|
inline |
构造轮询操作 / Construct a polling operation.
| status | 借用的原子状态,以 acquire 读取完成结果。 Borrowed atomic status; load completion with acquire ordering. |
Definition at line 78 of file operation.hpp.
|
inline |
标记轮询操作正在执行 / Mark a polling operation as running.
Definition at line 138 of file operation.hpp.
|
default |
复制通知描述符 / Copy the notification descriptor.
|
defaultnoexcept |
移动通知描述符 / Move the notification descriptor.
|
inline |
按通知方式报告完成结果 / Report completion using the selected mode.
| Status | 完成结果类型 / Completion result type. |
| in_isr | 当前是否在中断中 / Whether called in an ISR. |
| status | 传给回调或用于判断轮询成功状态的结果。 Result passed to the callback or used to set polling success or error. |
Definition at line 111 of file operation.hpp.
| Callback* LibXR::Operation< Args >::callback |
借用的回调对象 / Borrowed callback.
Definition at line 149 of file operation.hpp.
| Semaphore* LibXR::Operation< Args >::sem |
借用的信号量 / Borrowed semaphore.
Definition at line 152 of file operation.hpp.
| std::atomic<OperationPollingStatus>* LibXR::Operation< Args >::status |
借用的轮询状态 / Borrowed polling status.
Definition at line 156 of file operation.hpp.
| uint32_t LibXR::Operation< Args >::timeout |
等待超时值 / Wait timeout.
Definition at line 153 of file operation.hpp.
| OperationType LibXR::Operation< Args >::type |
当前通知方式 / Current notification mode.
Definition at line 160 of file operation.hpp.