|
morph 0.1.0
Asynchronous bridge between GUI thread and business models
|
Sequences reconnect → activate → bind → replay when connectivity returns. More...
#include <reconnect_coordinator.hpp>
Classes | |
| struct | Deps |
| Injected, host-supplied side effects. None may be null. Each is called on the offline strand. More... | |
Public Types | |
| using | Config = ReconnectCoordinatorConfig |
| Alias for the configuration struct. | |
Public Member Functions | |
| ReconnectCoordinator (Deps deps, ::morph::exec::IExecutor &executor, Config cfg=Config{}) | |
Constructs a coordinator with injected dependencies and tuning, running its sequences on a strand over executor. | |
| ~ReconnectCoordinator () | |
| Closes the offline strand: a sequence not yet started is dropped, one running on another thread is waited for. | |
| ReconnectCoordinator (const ReconnectCoordinator &)=delete | |
| ReconnectCoordinator & | operator= (const ReconnectCoordinator &)=delete |
| ReconnectCoordinator (ReconnectCoordinator &&)=delete | |
| ReconnectCoordinator & | operator= (ReconnectCoordinator &&)=delete |
| ::morph::async::Completion< ReconnectOutcome > | onOnline (::morph::exec::IExecutor &replyExec) |
| Runs the reconnect → activate → bind → replay sequence on the offline strand. | |
| void | onOffline () |
| Switches to the local backend and rebinds context, on the offline strand. | |
| ::morph::exec::IExecutor & | strand () noexcept |
| The offline strand, as an executor: what a SyncWorker that replays for this coordinator is given as its owner. | |
Sequences reconnect → activate → bind → replay when connectivity returns.
All side effects are injected via Deps. The coordinator contains only the retry loop, the ordering guarantees, and the abort checks. It performs no I/O and owns no thread: it owns a strand over the executor it is given, the offline strand, and runs onOnline()'s and onOffline()'s bodies there.
A SyncWorker given strand() as its owner drains inside the replay step when the step calls its run(), rather than after the task.
Definition at line 97 of file reconnect_coordinator.hpp.
Alias for the configuration struct.
Definition at line 100 of file reconnect_coordinator.hpp.
|
inline |
Constructs a coordinator with injected dependencies and tuning, running its sequences on a strand over executor.
| deps | Side-effect callbacks (all required, none null). |
| executor | Where the offline strand's tasks run: a worker pool. Borrowed: it must outlive this coordinator and keep running tasks until the coordinator is destroyed. |
| cfg | Retry tuning. |
A null Deps member is logged via morph::log::logError in all builds; construction still succeeds. Invoking the coordinator with any null member is undefined behaviour.
Definition at line 152 of file reconnect_coordinator.hpp.
|
inline |
Closes the offline strand: a sequence not yet started is dropped, one running on another thread is waited for.
Definition at line 159 of file reconnect_coordinator.hpp.
|
inline |
Runs the reconnect → activate → bind → replay sequence on the offline strand.
Posted as one task, after any onOnline()/onOffline() posted before it. Callable from any thread; returns at once.
| replyExec | Executor the outcome is delivered on and the caller attaches its callbacks on: the caller's own, or strand() for a caller that does not wait for it. Borrowed: it must outlive the returned Completion. |
replyExec. Definition at line 179 of file reconnect_coordinator.hpp.
|
inline |
Switches to the local backend and rebinds context, on the offline strand.
Idempotent at the policy level: safe to call when already local. Posted after any onOnline()/onOffline() posted before it. Callable from any thread; returns at once.
Definition at line 195 of file reconnect_coordinator.hpp.
|
inlinenodiscardnoexcept |
The offline strand, as an executor: what a SyncWorker that replays for this coordinator is given as its owner.
Definition at line 207 of file reconnect_coordinator.hpp.