class
MQTT::Pending(T)
- MQTT::Pending(T)
- Reference
- Object
Overview
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.
Defined in:
mqtt/pending.crConstructors
Instance Method Summary
- #completed? : Bool
-
#get(timeout : Time::Span | Nil = nil, description : String = "response") : T
Blocks the calling fiber until the response arrives.
- #reject(error : Exception) : Nil
- #resolve(value : T) : Nil
Constructor Detail
Instance Method Detail
Blocks the calling fiber until the response arrives.
Raises MQTT::TimeoutError if timeout elapses first.