|
libxr
Embedded C++ framework for bare-metal, RTOS and Linux
|
事件合并与回调串行化服务 / Event-coalescing serialized-callback service. More...
#include <serialized_service.hpp>
Public Member Functions | |
| template<typename Handler > | |
| bool | Invoke (uint32_t events, bool in_isr, Handler &&handler) noexcept |
| 发布事件并尝试取得执行权 / Publish events and attempt to claim execution. | |
| void | Publish (uint32_t events) noexcept |
| 为已有或确定会出现的执行者发布事件 / Publish for an active or guaranteed executor. | |
| SerializedService (const SerializedService &)=delete | |
| SerializedService & | operator= (const SerializedService &)=delete |
事件合并与回调串行化服务 / Event-coalescing serialized-callback service.
该服务用一个原子字保存执行权和低 31 位事件。Invoke() 发布事件并尝试取得执行权; 只有取得执行权的调用执行 handler,执行期间到达的事件由同一调用继续处理。未取得执行 权的调用只发布事件,其 handler 不会保存或稍后调用。事件位表示状态需要重新检查,不 表示发生次数。
This service stores execution ownership and low-31-bit events in one atomic word. Invoke() publishes events and attempts to claim execution. Only the caller that claims execution runs the handler; events arriving during execution are processed before ownership is released. A losing caller's handler is never retained or called later. Event bits request a state re-check and do not count occurrences.
Publish() 只记录事件,不负责唤醒或调度。service 以及 handler 访问的数据必须在所有活动 调用结束前保持有效;handler 不得抛出异常,也不得等待当前 service 所保护的进度。原子 操作的上下文限制、MMIO、DMA 同步和后端生命周期由调用方负责。
Publish() records an event but does not wake or schedule execution. The service and all data accessed by its handler must outlive every active call. Handlers must not throw or wait for progress protected by this service. Context restrictions for atomics, MMIO, DMA synchronization, and backend lifetime remain the caller's responsibility.
Definition at line 34 of file serialized_service.hpp.
|
inlinenoexcept |
发布事件并尝试取得执行权 / Publish events and attempt to claim execution.
| events | 非零低 31 位事件 / Nonzero event bits below bit 31. |
| in_isr | 当前调用上下文;仅传给取得执行权的调用 / Context of this call; used only if it claims execution. |
| handler | 签名 void(uint32_t, bool) / Callable as void(uint32_t, bool). |
Definition at line 49 of file serialized_service.hpp.
|
inlinenoexcept |
为已有或确定会出现的执行者发布事件 / Publish for an active or guaranteed executor.
| events | 低 31 位事件;零值不操作 / Low-31-bit events; zero is a no-op. |
Invoke;本方法本身不调度执行 / An executor or a later Invoke is guaranteed; this method does not schedule execution. Definition at line 74 of file serialized_service.hpp.