MQTT::Pending(T)
Inherits Reference / Object
A single-shot slot for a response we're expecting from the broker.
This replaces the promises that used to carry request/response plumbing.
Promise::DeferredPromise#get spawns a fiber and allocates a channel on
every call, and Promise.timeout costs another fiber and channel per
request. More importantly a promise runs its callbacks inline on whichever
fiber resolves it, which made it unsafe to resolve one while holding a lock.
Completion is signalled by closing a channel, which wakes every waiter rather than handing the value to whoever happens to receive first.
Constructors
new
SourceInstance methods
completed?
Sourceget(timeout : Time::Span | Nil = nil, description : String = "response") : T
Blocks the calling fiber until the response arrives.
Raises MQTT::TimeoutError if timeout elapses first.
reject(error : Exception) : Nil
Sourceresolve(value : T) : Nil
Source