Class: Smith::Workflow::Parallel::CancellationSignal
- Inherits:
-
Object
- Object
- Smith::Workflow::Parallel::CancellationSignal
- Defined in:
- lib/smith/workflow/parallel/cancellation_signal.rb
Instance Method Summary collapse
- #cancel!(error = nil) ⇒ Object
- #cancelled? ⇒ Boolean
-
#initialize ⇒ CancellationSignal
constructor
A new instance of CancellationSignal.
- #reason ⇒ Object
Constructor Details
#initialize ⇒ CancellationSignal
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
20 21 22 |
# File 'lib/smith/workflow/parallel/cancellation_signal.rb', line 20 def cancelled? @mutex.synchronize { @cancelled } end |
#reason ⇒ Object
24 25 26 |
# File 'lib/smith/workflow/parallel/cancellation_signal.rb', line 24 def reason @mutex.synchronize { @reason } end |