通用回调包装,支持动态参数传递 / Generic callback wrapper supporting dynamic argument passing
More...
|
| | Callback () |
| | 默认构造函数,创建空回调对象 / Default constructor creating an empty callback
|
| |
|
| Callback (const Callback &)=default |
| |
|
Callback & | operator= (const Callback &)=default |
| |
| | Callback (Callback &&other) noexcept |
| | 移动构造函数,转移回调对象的所有权 / Move constructor transferring callback ownership
|
| |
| Callback & | operator= (Callback &&other) noexcept |
| | 移动赋值运算符,转移回调对象的所有权 / Move assignment operator transferring callback ownership
|
| |
| template<typename... PassArgs> |
| void | Run (bool in_isr, PassArgs &&... args) const |
| |
| bool | Empty () const |
| | 检查回调是否为空 / Check whether the callback is empty
|
| |
|
template<typename BoundArgType , typename CallableType >
requires CallbackFunctionCompatible<CallableType, BoundArgType, Args...> |
| static Callback | Create (CallableType fun, BoundArgType arg) |
| | 创建回调对象并绑定回调函数与参数 / Create a callback instance with bound function and argument
|
| |
template<typename BoundArgType , typename CallableType >
requires CallbackFunctionCompatible<CallableType, BoundArgType, Args...> |
| static Callback | CreateGuarded (CallableType fun, BoundArgType arg) |
| | 创建带防重入保护的回调 / Create a guarded callback
|
| |
template<typename... Args>
class LibXR::Callback< Args >
通用回调包装,支持动态参数传递 / Generic callback wrapper supporting dynamic argument passing
- Template Parameters
-
| Args | 额外的参数类型列表 / Additional argument types |
Definition at line 143 of file libxr_cb.hpp.
template<typename... Args>
template<typename BoundArgType , typename CallableType >
requires CallbackFunctionCompatible<CallableType, BoundArgType, Args...>
创建回调对象并绑定回调函数与参数 / Create a callback instance with bound function and argument
- Template Parameters
-
| BoundArgType | 绑定参数类型 / Bound argument type |
| CallableType | 回调可调用对象类型 / Callback callable type |
- Parameters
-
| fun | 需要绑定的回调函数 / Callback function to bind |
| arg | 绑定的参数值 / Bound argument value |
- Returns
- Callback 实例 / Created Callback instance
- Note
- 预期用法是初始化阶段创建并长期持有; 运行时高频创建/销毁不属于设计目标。 Intended usage is initialization-time creation with long-lived retention; runtime churn-style create/destroy patterns are outside the intended model.
Definition at line 167 of file libxr_cb.hpp.
168 {
169 using FunctionType = typename CallbackBlock<BoundArgType, Args...>::FunctionType;
170 auto cb_block =
171 new CallbackBlock<BoundArgType, Args...>(static_cast<FunctionType>(fun),
172 std::move(arg));
174 }
Callback()
默认构造函数,创建空回调对象 / Default constructor creating an empty callback
template<typename... Args>
template<typename BoundArgType , typename CallableType >
requires CallbackFunctionCompatible<CallableType, BoundArgType, Args...>
创建带防重入保护的回调 / Create a guarded callback
- Template Parameters
-
| BoundArgType | 绑定参数类型 / Bound argument type |
| CallableType | 回调可调用对象类型 / Callback callable type |
- Parameters
-
| fun | 需要绑定的回调函数 / Callback function to bind |
| arg | 绑定的参数值 / Bound argument value |
- Returns
- Callback 实例 / Created Callback instance
- Note
- 该 guarded callback 预期用于单条逻辑回调链上的递归压平, 不承担任意多上下文串行化。 Guarded callbacks are meant for self-recursive flattening on one logical callback chain, not arbitrary multi-context serialization.
Definition at line 192 of file libxr_cb.hpp.
193 {
194 using FunctionType = typename CallbackBlock<BoundArgType, Args...>::FunctionType;
195 auto cb_block =
196 new GuardedCallbackBlock<BoundArgType, Args...>(static_cast<FunctionType>(fun),
197 std::move(arg));
199 }