|
Flow 3.0.0
Flow project: Full implementation reference.
|
A single boolean flag, armed via arm_next_poll() (typically from another thread) and both checked and disarmed – cheaply enough for the hottest of paths – via poll_armed(). More...
#include <thread_lcl.hpp>
Public Member Functions | |
| Poll_flag () | |
Creates flag in disarmed state: poll_armed() shall return false until the first arm_next_poll(). More... | |
| void | arm_next_poll () |
From any thread: causes the next poll_armed() call to return true (once). More... | |
| bool | poll_armed () |
If armed: disarms and returns true; else returns false. More... | |
Private Attributes | |
| std::atomic< bool > | m_armed |
The flag; true = armed. More... | |
A single boolean flag, armed via arm_next_poll() (typically from another thread) and both checked and disarmed – cheaply enough for the hottest of paths – via poll_armed().
It is the signaling building block of the Polled_shared_state pattern (see Polled_shared_state doc header), wherein one embeds a Poll_flag in each per-thread state of a Thread_local_state_registry; but it is usable stand-alone, wherever a thread must cheaply, opportunistically notice a rare request from another thread.
Definition at line 817 of file thread_lcl.hpp.
|
inline |
Creates flag in disarmed state: poll_armed() shall return false until the first arm_next_poll().
Definition at line 1325 of file thread_lcl.hpp.
|
inline |
From any thread: causes the next poll_armed() call to return true (once).
If already armed, it stays armed (this is not a counter).
If arming signals a change to some shared data (e.g., Polled_shared_state::while_locked()-guarded state), finish writing that data – and unlock – before calling this; the memory-ordering internals then guarantee the poll_armed() caller sees the writes.
Definition at line 1331 of file thread_lcl.hpp.
References m_armed.
|
inline |
If armed: disarms and returns true; else returns false.
Cheap enough (one atomic op with near-minimal ordering constraints; no locking) for the hottest of paths, particularly when it returns false.
Definition at line 1358 of file thread_lcl.hpp.
References m_armed.
|
private |
The flag; true = armed.
Definition at line 850 of file thread_lcl.hpp.
Referenced by arm_next_poll(), and poll_armed().