Class: Farce::Abstract::TimerQueue::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/farce/abstract/timer_queue.rb

Overview

A handle for canceling a scheduled value. Entries keep the stored value private, so canceling a moved value does not claim it. With local queues, cancellation uses the current scope.

Examples:

Cancel a delayed value

queue = Farce::TimerQueue.new
entry = queue.push(:work, delay: 60)
entry.delete # => true

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#clock ⇒ Float (readonly)

Returns the scheduled monotonic clock time.

Returns:

  • (Float) —

    the scheduled monotonic clock time



21
22
23
# File 'lib/farce/abstract/timer_queue.rb', line 21

def clock
  @clock
end

#queue ⇒ Farce::Abstract::TimerQueue (readonly)

Returns the queue that created this entry.

Returns:



24
25
26
# File 'lib/farce/abstract/timer_queue.rb', line 24

def queue
  @queue
end

Instance Method Details

#delete ⇒ Boolean Also known as: cancel

Cancel the scheduled value by identity at its exact timestamp. If the same value was queued more than once at that timestamp, delete the oldest match.

Returns:

  • (Boolean) —

    whether a value was deleted

Raises:



38
# File 'lib/farce/abstract/timer_queue.rb', line 38

def delete = queue.delete(@value, at: clock, compare_by_identity: true)