Class: Ibex::Runtime::CancellationToken

Inherits:
Object
  • Object
show all
Defined in:
lib/json5/generated_parser.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.

RBS:

  • () -> void



3969
3970
3971
3972
# File 'lib/json5/generated_parser.rb', line 3969

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

Instance Method Details

#cancel!Object

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

RBS:

  • () -> true



3976
3977
3978
3979
# File 'lib/json5/generated_parser.rb', line 3976

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

#cancelled?Boolean

RBS:

  • () -> bool

Returns:

  • (Boolean)


3983
3984
3985
# File 'lib/json5/generated_parser.rb', line 3983

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