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

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

Instance Method Summary collapse

Constructor Details

#initializeCancellationSignal

Returns a new instance of CancellationSignal.



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

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

Instance Method Details

#cancel!(error = nil) ⇒ Object



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

def cancel!(error = nil)
  @mutex.synchronize do
    @reason = Parallel.preferred_error([@reason, error])
    @cancelled = true
  end
end

#cancelled?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/smith/workflow/parallel/cancellation_signal.rb', line 20

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

#reasonObject



24
25
26
# File 'lib/smith/workflow/parallel/cancellation_signal.rb', line 24

def reason
  @mutex.synchronize { @reason }
end