Class: Ibex::Runtime::CancellationToken
- Inherits:
-
Object
- Object
- Ibex::Runtime::CancellationToken
- Defined in:
- lib/ibex/runtime/syntax_session.rb
Overview
Thread-safe cooperative cancellation state for one or more operations.
Instance Method Summary collapse
-
#cancel! ⇒ Object
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.
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
59 60 61 |
# File 'lib/ibex/runtime/syntax_session.rb', line 59 def cancelled? @mutex.synchronize { @cancelled } end |