Class: Ibex::Runtime::CancellationToken

Inherits:
Object
  • Object
show all
Defined in:
lib/ibex/runtime/syntax_session.rb

Overview

Thread-safe cooperative cancellation state for one or more operations.

Instance Method Summary collapse

Constructor Details

#initializeCancellationToken

Returns a new instance of CancellationToken.



45
46
47
48
# File 'lib/ibex/runtime/syntax_session.rb', line 45

def initialize
  @mutex = Mutex.new #: Mutex
  @cancelled = false #: bool
end

Instance Method Details

#cancel!Object

rubocop:disable Naming/PredicateMethod -- command mutation convention.



52
53
54
55
# File 'lib/ibex/runtime/syntax_session.rb', line 52

def cancel!
  @mutex.synchronize { @cancelled = true }
  true
end

#cancelled?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/ibex/runtime/syntax_session.rb', line 59

def cancelled?
  @mutex.synchronize { @cancelled }
end