class Flor::Pro::Concurrence
Constants
- REWRITE_AS_ATTS
Public Instance Methods
Source
# File lib/flor/punit/concurrence.rb, line 338 def add super i = Flor.child_id(message['tnid']) ts = message['trees'] @node['branch_count'] += ts.size ts .collect.with_index { |t, j| pl = Flor.dup(message['payload'] || node_payload.copy) execute_child(i + j, 0, 'payload' => pl) } .flatten(1) end
Calls superclass method
Flor::Procedure#add
Source
# File lib/flor/punit/concurrence.rb, line 301 def pre_execute @node['atts'] = [] pre_execute_rewrite end
Source
# File lib/flor/punit/concurrence.rb, line 308 def receive_last_att return wrap_reply unless children[@ncid] branches = (@ncid..children.size - 1).to_a @node['branch_count'] = branches.count branches .map { |i| execute_child(i, 0, 'payload' => payload.copy_current) } .flatten(1) # # call execute for each of the (non _att) children end
Source
# File lib/flor/punit/concurrence.rb, line 322 def receive_non_att if message['from_on'] super #receive_from_on elsif Flor.same_sub?(nid, from) receive_from_branch elsif from_error_handler? wrap_reply elsif @node['on_receive_nids'] && @node['on_receive_nids'][0] == from receive_from_receiver else receive_from_merger end end
Calls superclass method
Flor::Procedure#receive_non_att
Protected Instance Methods
Source
# File lib/flor/punit/concurrence.rb, line 368 def make_on_def(cn, l) c0 = cn.length == 1 ? cn[0] : nil return c0 if Flor.is_definition_tree?(c0) return make_on_def(c0[1], l) if Flor.is_att_tree?(c0) [ 'def', cn, l ] end
Source
# File lib/flor/punit/concurrence.rb, line 396 def pre_execute_rewrite t = tree t1 = t[1] return if t1.empty? atts, cldn = t1.inject([ [], [] ]) { |r, ct| if ct[0] == '_att' r[0] << ct elsif REWRITE_AS_ATTS.include?(ct[0]) r[0] << rewrite_as_attribute(ct) else r[1] << ct end r } nt1 = atts + cldn @node['tree'] = [ t[0], nt1, *t[2..-1] ] \ if nt1 != t1 end
heads of the child nodes that should get rewritten as attributes of the concurrence …
Source
# File lib/flor/punit/concurrence.rb, line 359 def receive_from_child_when_closed ms = receive return [] if ms.empty? pop_on_receive_last || ms end
used by ReceiveAndMerge to determine procedure end
Source
# File lib/flor/punit/concurrence.rb, line 378 def rewrite_as_attribute(child_tree) ct0, ct1, ct2 = child_tree k = [ ct0, [], ct2 ] v = make_on_def(ct1, ct2) [ '_att', [ k, v ], ct2 ] end