Class: Ibex::Runtime::CancellationToken
- Inherits:
-
Object
- Object
- Ibex::Runtime::CancellationToken
- 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
-
#cancel! ⇒ true
rubocop:disable Naming/PredicateMethod -- command mutation convention.
- #cancelled? ⇒ Boolean
-
#initialize ⇒ CancellationToken
constructor
A new instance of CancellationToken.
Constructor Details
#initialize ⇒ CancellationToken
Returns a new instance of CancellationToken.
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.
51 52 53 54 |
# File 'lib/ibex/runtime/syntax_session.rb', line 51 def cancel! @mutex.synchronize { @cancelled = true } true end |
#cancelled? ⇒ Boolean
58 59 60 |
# File 'lib/ibex/runtime/syntax_session.rb', line 58 def cancelled? @mutex.synchronize { @cancelled } end |