|
MetaImGUI 1.0.0
ImGui Application Template for C++20
|
A single-threaded multicast event source. More...
#include <Signal.h>
Public Types | |
| using | SlotId = std::size_t |
| using | Slot = std::function< void(Args...)> |
Public Member Functions | |
| Signal ()=default | |
| Signal (const Signal &)=delete | |
| Signal & | operator= (const Signal &)=delete |
| Signal (Signal &&)=delete | |
| Signal & | operator= (Signal &&)=delete |
| ~Signal ()=default | |
| Connection | Connect (Slot slot) |
| Subscribe a slot. | |
| void | Emit (Args... args) const |
| Fire the signal. | |
| std::size_t | SlotCount () const noexcept |
A single-threaded multicast event source.
Slots receive every Emit() in connection order. The Signal stores its slot table in a shared control block, so a Connection that outlives the Signal harmlessly disconnects nothing rather than dereferencing a dangling pointer.
Not thread-safe — Emit / Connect / Disconnect must all happen on the same thread (the UI thread, in this codebase). Cross-thread fan-out is the caller's job (see the m_pendingUpdateResult mutex hand-off in Application).
| using MetaImGUI::Signal< Args >::Slot = std::function<void(Args...)> |
| using MetaImGUI::Signal< Args >::SlotId = std::size_t |
|
default |
|
delete |
|
delete |
|
default |
|
inline |
Subscribe a slot.
Returns a RAII handle that disconnects on drop.
Definition at line 122 of file Signal.h.
Referenced by MetaImGUI::Application::Initialize().
|
inline |
Fire the signal.
Each connected slot is invoked once with args.
Slots are invoked from a snapshot, so a slot that disconnects itself or another slot during emission is safe — the snapshot is unaffected.
Definition at line 139 of file Signal.h.
Referenced by MetaImGUI::UIRenderer::RenderMainWindow(), and MetaImGUI::UIRenderer::RenderMenuBar().
|
delete |
|
delete |
|
inlinenoexcept |