Class: Ibex::Runtime::CancellationToken

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

Overview

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

Instance Method Summary collapse

Constructor Details

#initializeCancellationToken

Returns a new instance of CancellationToken.

RBS:

  • () -> void



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

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

Instance Method Details

#cancel!true

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

RBS:

  • () -> true

Returns:

  • (true)


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

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

#cancelled?Boolean

RBS:

  • () -> bool

Returns:

  • (Boolean)


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

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