libxr
1.0
Want to be the best embedded framework
|
Defines an operation with different execution modes. More...
#include <libxr_rw.hpp>
Public Types | |
enum class | OperationType : uint8_t { CALLBACK , BLOCK , POLLING , NONE } |
enum class | OperationPollingStatus : uint8_t { READY , RUNNING , DONE } |
using | Callback = LibXR::Callback<Args...> |
Public Member Functions | |
Operation () | |
Default constructor, initializes with NONE type. | |
Operation (Semaphore &sem, uint32_t timeout=UINT32_MAX) | |
Constructs a blocking operation with a semaphore and timeout. | |
Operation (Callback &callback) | |
Constructs a callback-based operation. | |
Operation (OperationPollingStatus &status) | |
Constructs a polling operation. | |
Operation & | operator= (const Operation &op) |
Copy assignment operator. | |
Operation & | operator= (Operation &&op) noexcept |
Move assignment operator. | |
template<typename InitOperation , typename = std::enable_if_t<std::is_same_v<std::decay_t<InitOperation>, Operation>>> | |
Operation (InitOperation &&op) | |
构造一个新的 Operation 对象(初始化操作)。 Constructs a new Operation object (initialization operation). | |
template<typename... Status> | |
void | UpdateStatus (bool in_isr, Status &&...status) |
Updates operation status based on type. | |
void | MarkAsRunning () |
标记操作为运行状态。 Marks the operation as running. | |
Data Fields | ||
union { | ||
Callback * callback | ||
struct { | ||
Semaphore * sem | ||
uint32_t timeout | ||
} sem_info | ||
OperationPollingStatus * status | ||
} | data | |
OperationType | type | |
Defines an operation with different execution modes.
定义了一种具有不同执行模式的操作。
Args | The parameter types for callback operations. |
Args | 用于回调操作的参数类型。 |
Definition at line 28 of file libxr_rw.hpp.
using LibXR::Operation< Args >::Callback = LibXR::Callback<Args...> |
Definition at line 31 of file libxr_rw.hpp.
|
strong |
Polling operation status. 轮询操作的状态。
Definition at line 45 of file libxr_rw.hpp.
|
strong |
Operation types. 操作类型。
Definition at line 35 of file libxr_rw.hpp.
|
inline |
Default constructor, initializes with NONE type.
默认构造函数,初始化为NONE类型。
Definition at line 54 of file libxr_rw.hpp.
|
inline |
Constructs a blocking operation with a semaphore and timeout.
使用信号量和超时构造阻塞操作。
sem | Semaphore reference. |
timeout | Timeout duration (default is maximum). |
Definition at line 64 of file libxr_rw.hpp.
|
inline |
Constructs a callback-based operation.
构造基于回调的操作。
callback | Callback function reference. |
Definition at line 75 of file libxr_rw.hpp.
|
inline |
Constructs a polling operation.
构造轮询操作。
status | Reference to polling status. |
Definition at line 85 of file libxr_rw.hpp.
|
inline |
构造一个新的 Operation 对象(初始化操作)。 Constructs a new Operation object (initialization operation).
该构造函数用于初始化一个 Operation 对象,接收一个初始化操作作为参数。 This constructor initializes an Operation object with an initialization operation as a parameter.
Definition at line 161 of file libxr_rw.hpp.
|
inline |
标记操作为运行状态。 Marks the operation as running.
该函数用于在操作类型为 POLLING
时,将 data.status
设置为 RUNNING
, 以指示该操作正在执行中。 This function sets data.status
to RUNNING
when the operation type is POLLING
, indicating that the operation is currently in progress.
OperationType::POLLING
类型的操作,其他类型不会受到影响。 This method only applies to operations of type OperationType::POLLING
, and other types remain unaffected. Definition at line 204 of file libxr_rw.hpp.
|
inline |
Copy assignment operator.
复制赋值运算符。
op | Another Operation instance. |
Definition at line 96 of file libxr_rw.hpp.
|
inlinenoexcept |
Move assignment operator.
移动赋值运算符。
op | Another Operation instance. |
Definition at line 126 of file libxr_rw.hpp.
|
inline |
Updates operation status based on type.
根据类型更新操作状态。
in_isr | Indicates if executed within an interrupt. |
args | Parameters passed to the callback. |
Definition at line 173 of file libxr_rw.hpp.
Callback* LibXR::Operation< Args >::callback |
Definition at line 216 of file libxr_rw.hpp.
union { ... } LibXR::Operation< Args >::data |
Data storage for different operation types. 存储不同操作类型的数据。
Semaphore* LibXR::Operation< Args >::sem |
Definition at line 219 of file libxr_rw.hpp.
OperationPollingStatus* LibXR::Operation< Args >::status |
Definition at line 222 of file libxr_rw.hpp.
uint32_t LibXR::Operation< Args >::timeout |
Definition at line 220 of file libxr_rw.hpp.
OperationType LibXR::Operation< Args >::type |
Operation type. 操作类型。
Definition at line 227 of file libxr_rw.hpp.