Class: Plumbing::Actor::Deferral
- Defined in:
- lib/plumbing/actor/deferral.rb
Overview
An opaque handle for a scheduled (deferred) message. Cancelling sets a mutex-guarded flag that the worker's timer checks before dispatching. The flag itself is race-safe; a cancel landing in the tiny window after the check still lets one (benign, in-order) message through — the operation layer's generation token discards such a stale fire.
Instance Method Summary collapse
- #cancel ⇒ Object
- #cancelled? ⇒ Boolean
-
#initialize ⇒ Deferral
constructor
A new instance of Deferral.
Constructor Details
#initialize ⇒ Deferral
Returns a new instance of Deferral.
11 12 13 14 |
# File 'lib/plumbing/actor/deferral.rb', line 11 def initialize @lock = Mutex.new @cancelled = false end |
Instance Method Details
#cancel ⇒ Object
16 |
# File 'lib/plumbing/actor/deferral.rb', line 16 def cancel = @lock.synchronize { @cancelled = true } |
#cancelled? ⇒ Boolean
18 |
# File 'lib/plumbing/actor/deferral.rb', line 18 def cancelled? = @lock.synchronize { @cancelled } |