|
morph 0.1.0
Asynchronous bridge between GUI thread and business models
|
A Dispatcher that holds a queued call the server cannot be reached for, and replays it on reconnect. More...
#include <queueing_dispatcher.hpp>
Public Member Functions | |
| QueueingDispatcher (Dispatcher &inner, exec::IExecutor *owner) | |
Queues around inner, delivering on owner. | |
| std::shared_ptr< ModelChannel > | bind (std::string const &typeId, bridge::BindSharing sharing, std::string const &instanceKey) override |
| Binds through the wrapped dispatcher. | |
| void | replay () |
| Re-sends the held calls, oldest first, one at a time; each caller's completion settles with its replay. A call that still cannot reach the server stops the replay and stays held, with every call after it. Nothing happens while a replay is already running. | |
| std::size_t | held () const noexcept |
| How many calls are held. | |
| void | setOnHeld (std::function< void(std::size_t)> observer) |
| Called with the held count whenever it changes, such as for a "waiting to send" indicator. | |
| Public Member Functions inherited from morph::ui::Dispatcher | |
| Dispatcher (Dispatcher const &)=delete | |
| Dispatcher & | operator= (Dispatcher const &)=delete |
| Dispatcher (Dispatcher &&)=delete | |
| Dispatcher & | operator= (Dispatcher &&)=delete |
A Dispatcher that holds a queued call the server cannot be reached for, and replays it on reconnect.
A call made with CallOptions::queueOffline goes through the wrapped dispatcher. When it fails with backend::DisconnectedError it is held, and the completion the caller has stays pending: the mutation stays pending and its elements stale. Once anything is held, a later queued call joins the back of the queue without being tried, so the server sees the calls in the order they were made. replay re-sends the held calls, oldest first and one at a time, and settles each caller's completion with the replay's reply or failure; a replay that cannot reach the server either stops the replay and stays held for the next one. A call without queueOffline, and an evaluation, are never held: offline, they fail at once.
Single-threaded: every call, and replay, runs on the owner the replies are delivered on. Held calls keep their channel, and with it the model binding, until they settle.
Definition at line 35 of file queueing_dispatcher.hpp.
|
inline |
Queues around inner, delivering on owner.
| inner | The dispatcher calls go through. Borrowed: it must outlive this one and every channel it bound. |
| owner | The executor replies are delivered on: the runtime's owner. Borrowed. |
Definition at line 40 of file queueing_dispatcher.hpp.
|
inlinenodiscardoverridevirtual |
Binds through the wrapped dispatcher.
| typeId | The model's registered type id. |
| sharing | Private, or shared. |
| instanceKey | For a shared binding, the instance key; empty for the model's shared singleton. |
Implements morph::ui::Dispatcher.
Definition at line 48 of file queueing_dispatcher.hpp.
|
inline |
Re-sends the held calls, oldest first, one at a time; each caller's completion settles with its replay. A call that still cannot reach the server stops the replay and stays held, with every call after it. Nothing happens while a replay is already running.
Definition at line 56 of file queueing_dispatcher.hpp.
|
inlinenodiscardnoexcept |
|
inline |
Called with the held count whenever it changes, such as for a "waiting to send" indicator.
| observer | The observer; empty for none. |
Definition at line 64 of file queueing_dispatcher.hpp.