Class: Kitsune::Kit::Cancellation

Inherits:
Object
  • Object
show all
Defined in:
lib/kitsune/kit/cancellation.rb

Defined Under Namespace

Classes: Cancelled

Instance Method Summary collapse

Constructor Details

#initializeCancellation

Returns a new instance of Cancellation.



8
9
10
11
# File 'lib/kitsune/kit/cancellation.rb', line 8

def initialize
  @cancelled = false
  @mutex = Mutex.new
end

Instance Method Details

#cancel!Object



13
# File 'lib/kitsune/kit/cancellation.rb', line 13

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

#cancelled?Boolean

Returns:

  • (Boolean)


14
# File 'lib/kitsune/kit/cancellation.rb', line 14

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

#check!Object

Raises:



16
17
18
# File 'lib/kitsune/kit/cancellation.rb', line 16

def check!
  raise Cancelled, "operation cancelled" if cancelled?
end