Class: Ruote::Exp::ReserveExpression
- Inherits:
-
FlowExpression
- Object
- FlowExpression
- Ruote::Exp::ReserveExpression
- Defined in:
- lib/ruote/exp/fe_reserve.rb
Overview
Prevents two process branches from executing at the same time.
pdef = Ruote.process_definition :name => 'test' do
concurrence do
reserve :mutex => 'a' do
alpha
end
reserve 'a' do
alpha
end
end
end
(Nice and tiny example, turns a concurrence into a sequence…)
Constant Summary
Constants inherited from FlowExpression
FlowExpression::COMMON_ATT_KEYS
Instance Attribute Summary
Attributes inherited from FlowExpression
Instance Method Summary collapse
Methods inherited from FlowExpression
#ancestor?, #att, #attribute, #attribute_text, #attributes, #compile_atts, #compile_variables, do_action, #do_apply, #do_cancel, #do_fail, #do_pause, #do_persist, #do_reply, #do_resume, #do_unpersist, #expand_atts, #fei, fetch, from_h, #handle_on_error, #has_attribute, #initial_persist, #initialize, #iterative_var_lookup, #launch_sub, #lookup_on_error, #lookup_val, #lookup_val_prefix, #lookup_variable, #name, names, #parent, #parent_id, #persist_or_raise, #reply_to_parent, #set_variable, #to_h, #tree, #tree_children, #try_persist, #try_unpersist, #unpersist_or_raise, #unset_variable, #update_tree, #variables
Methods included from WithMeta
Methods included from WithH
Constructor Details
This class inherits a constructor from Ruote::Exp::FlowExpression
Instance Method Details
#apply ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/ruote/exp/fe_reserve.rb', line 48 def apply return reply_to_parent(h.applied_workitem) if tree_children.empty? h.mutex_name = attribute(:mutex) || attribute_text h.mutex_name = 'reserve' if h.mutex_name.strip == '' raise( ArgumentError.new("can't bind reserve mutex at engine level") ) if h.mutex_name.match(/^\/\//) set_mutex end |
#cancel(flavour) ⇒ Object
69 70 71 72 73 74 |
# File 'lib/ruote/exp/fe_reserve.rb', line 69 def cancel(flavour) super release_mutex end |
#enter ⇒ Object
76 77 78 79 |
# File 'lib/ruote/exp/fe_reserve.rb', line 76 def enter apply_child(0, h.applied_workitem) end |
#reply(workitem) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/ruote/exp/fe_reserve.rb', line 62 def reply(workitem) release_mutex reply_to_parent(workitem) end |