Class: Plumbing::Actor::Deferral

Inherits:
Object
  • Object
show all
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

Constructor Details

#initializeDeferral

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

#cancelObject



16
# File 'lib/plumbing/actor/deferral.rb', line 16

def cancel = @lock.synchronize { @cancelled = true }

#cancelled?Boolean

Returns:

  • (Boolean)


18
# File 'lib/plumbing/actor/deferral.rb', line 18

def cancelled? = @lock.synchronize { @cancelled }