Class: Chamomile::CancelToken

Inherits:
Object
  • Object
show all
Defined in:
lib/chamomile/commands.rb

Overview

A cancel token for cancellable commands.

Instance Method Summary collapse

Constructor Details

#initializeCancelToken

Returns a new instance of CancelToken.



54
55
56
# File 'lib/chamomile/commands.rb', line 54

def initialize
  @cancelled = Concurrent::AtomicBoolean.new(false)
end

Instance Method Details

#cancel!Object



58
59
60
# File 'lib/chamomile/commands.rb', line 58

def cancel!
  @cancelled.make_true
end

#cancelled?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/chamomile/commands.rb', line 62

def cancelled?
  @cancelled.true?
end