FlowExpression
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...)
# 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
# File lib/ruote/exp/fe_reserve.rb, line 108 def release_mutex target, var = locate_var(h.mutex_name) mutex = target.variables[var] mutex.last.shift r = target.try_persist return release_mutex if r != nil next_fei = mutex.last.first Ruote::Exp::FlowExpression.fetch(@context, next_fei).enter if next_fei end
# File lib/ruote/exp/fe_reserve.rb, line 83 def set_mutex target, var = locate_var(h.mutex_name) val = target.variables[var] # [ 'mutex', name, [ fei0, fei1, ... ] ] mutex = val ? val : [ 'mutex', var, [] ] mutex.last << h.fei target.variables[var] = mutex r = target.try_persist return set_mutex if r != nil if mutex.last.first == h.fei enter else persist_or_raise end end
Generated with the Darkfish Rdoc Generator 2.