Class: Smith::Workflow::PreparedStepExecutionScope
- Inherits:
-
Object
- Object
- Smith::Workflow::PreparedStepExecutionScope
- Defined in:
- lib/smith/workflow/prepared_step_execution_scope.rb
Instance Method Summary collapse
- #activate!(thread) ⇒ Object
- #active_for?(thread) ⇒ Boolean
- #binding_accessible_for?(thread) ⇒ Boolean
- #close!(thread = nil) ⇒ Object
-
#initialize ⇒ PreparedStepExecutionScope
constructor
A new instance of PreparedStepExecutionScope.
Constructor Details
#initialize ⇒ PreparedStepExecutionScope
Returns a new instance of PreparedStepExecutionScope.
8 9 10 11 12 |
# File 'lib/smith/workflow/prepared_step_execution_scope.rb', line 8 def initialize @mutex = Mutex.new @phase = :issued @thread = nil end |
Instance Method Details
#activate!(thread) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/smith/workflow/prepared_step_execution_scope.rb', line 14 def activate!(thread) @mutex.synchronize do raise WorkflowError, "prepared-step execution scope is no longer available" unless @phase == :issued @phase = :active @thread = thread end end |
#active_for?(thread) ⇒ Boolean
34 35 36 |
# File 'lib/smith/workflow/prepared_step_execution_scope.rb', line 34 def active_for?(thread) @mutex.synchronize { @phase == :active && @thread.equal?(thread) } end |
#binding_accessible_for?(thread) ⇒ Boolean
38 39 40 41 42 |
# File 'lib/smith/workflow/prepared_step_execution_scope.rb', line 38 def binding_accessible_for?(thread) @mutex.synchronize do @phase == :issued || (@phase == :active && @thread.equal?(thread)) end end |
#close!(thread = nil) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/smith/workflow/prepared_step_execution_scope.rb', line 23 def close!(thread = nil) @mutex.synchronize do if @phase == :active && thread && !@thread.equal?(thread) raise WorkflowError, "prepared-step execution scope belongs to another thread" end @phase = :closed @thread = nil end end |