Class: Smith::Workflow::Parallel::CancellationSignal

Inherits:
Struct
  • Object
show all
Defined in:
lib/smith/workflow/parallel/cancellation_signal.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCancellationSignal

Returns a new instance of CancellationSignal.



7
8
9
# File 'lib/smith/workflow/parallel/cancellation_signal.rb', line 7

def initialize
  super(false, Mutex.new)
end

Instance Attribute Details

#cancelledObject

Returns the value of attribute cancelled

Returns:

  • (Object)

    the current value of cancelled



6
7
8
# File 'lib/smith/workflow/parallel/cancellation_signal.rb', line 6

def cancelled
  @cancelled
end

#mutexObject

Returns the value of attribute mutex

Returns:

  • (Object)

    the current value of mutex



6
7
8
# File 'lib/smith/workflow/parallel/cancellation_signal.rb', line 6

def mutex
  @mutex
end

Instance Method Details

#cancel!Object



11
12
13
# File 'lib/smith/workflow/parallel/cancellation_signal.rb', line 11

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

#cancelled?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/smith/workflow/parallel/cancellation_signal.rb', line 15

def cancelled?
  mutex.synchronize { cancelled }
end