|
libxr
1.0
Want to be the best embedded framework
|
回调函数封装块,提供重入保护与参数绑定 / Callback block with argument binding and reentrancy guard More...
#include <libxr_cb.hpp>
Public Types | |
| using | FunctionType = void (*)(bool, ArgType, Args...) |
| 回调函数类型定义 / Callback function type definition | |
Public Member Functions | |
| template<typename FunType , typename ArgT > | |
| CallbackBlock (FunType &&fun, ArgT &&arg) | |
| 构造回调块,绑定回调函数与参数 / Construct a callback block with bound function and argument | |
| void | Call (bool in_isr, Args... args) |
| 触发回调执行(带重入保护) / Trigger callback execution with reentrancy guard | |
| CallbackBlock (const CallbackBlock &other)=delete | |
| 禁用拷贝构造与拷贝赋值 / Copy construction and copy assignment are disabled | |
| CallbackBlock & | operator= (const CallbackBlock &other)=delete |
| CallbackBlock (CallbackBlock &&other) noexcept | |
| 移动构造函数,转移回调函数与参数 / Move constructor transferring function and argument | |
| CallbackBlock & | operator= (CallbackBlock &&other) noexcept |
| 移动赋值运算符,转移回调函数与参数 / Move assignment operator transferring function and argument | |
Private Attributes | |
| bool | running_ = false |
| bool | pending_ = false |
| std::tuple< std::decay_t< Args >... > | pending_args_ {} |
| void(* | fun_ )(bool, ArgType, Args...) |
| 绑定的回调函数 / Bound callback function | |
| ArgType | arg_ |
| 绑定的参数 / Bound argument | |
| bool | in_isr_ = false |
| 是否在中断上下文中执行 / Whether executed in ISR context | |
回调函数封装块,提供重入保护与参数绑定 / Callback block with argument binding and reentrancy guard
当回调正在执行时再次触发(重入),不会递归调用回调函数,而是缓存一次“待执行请求”; 待当前执行结束后在同一调用点以循环方式补跑,从而避免无限嵌套(trampoline 扁平化)。 When reentered while running, the callback is not invoked recursively. Instead, one pending request is cached and replayed in a loop after the current invocation completes, flattening recursion via a trampoline-style execution.
| ArgType | 绑定的第一个参数类型 / Type of the first bound argument |
| Args | 额外的参数类型列表 / Additional argument types |
Definition at line 27 of file libxr_cb.hpp.
| using LibXR::CallbackBlock< ArgType, Args >::FunctionType = void (*)(bool, ArgType, Args...) |
回调函数类型定义 / Callback function type definition
Definition at line 37 of file libxr_cb.hpp.
|
inline |
构造回调块,绑定回调函数与参数 / Construct a callback block with bound function and argument
| FunType | 函数类型 / Function type |
| ArgT | 绑定参数类型 / Bound argument type |
| fun | 需要调用的回调函数 / Callback function to be invoked |
| arg | 绑定的参数值 / Bound argument value |
Definition at line 49 of file libxr_cb.hpp.
|
inlinenoexcept |
移动构造函数,转移回调函数与参数 / Move constructor transferring function and argument
| other | 另一个 CallbackBlock 实例 / Another CallbackBlock instance |
Definition at line 111 of file libxr_cb.hpp.
|
inline |
触发回调执行(带重入保护) / Trigger callback execution with reentrancy guard
| in_isr | 是否在中断上下文中执行 / Whether executed in ISR context |
| args | 额外参数 / Additional arguments |
Definition at line 66 of file libxr_cb.hpp.
|
inlinenoexcept |
移动赋值运算符,转移回调函数与参数 / Move assignment operator transferring function and argument
| other | 另一个 CallbackBlock 实例 / Another CallbackBlock instance |
Definition at line 125 of file libxr_cb.hpp.
|
private |
绑定的参数 / Bound argument
Definition at line 138 of file libxr_cb.hpp.
|
private |
绑定的回调函数 / Bound callback function
Definition at line 137 of file libxr_cb.hpp.
|
private |
是否在中断上下文中执行 / Whether executed in ISR context
Definition at line 139 of file libxr_cb.hpp.
|
private |
Definition at line 30 of file libxr_cb.hpp.
|
private |
Definition at line 31 of file libxr_cb.hpp.
|
private |
Definition at line 29 of file libxr_cb.hpp.