Class: Flor::Pro::ConcurrentIterator
- Inherits:
-
Flor::Procedure
- Object
- Node
- Flor::Procedure
- Flor::Pro::ConcurrentIterator
- Includes:
- ReceiveAndMerge
- Defined in:
- lib/flor/punit/c_iterator.rb
Overview
Parent class for “c-for-each” and “c-map”
Constant Summary
Constants inherited from Flor::Procedure
Flor::Procedure::RVARS, Flor::Procedure::TRUE_ATTS
Instance Attribute Summary
Attributes inherited from Node
Instance Method Summary collapse
Methods inherited from Flor::Procedure
[], core?, #debug_msg, #debug_tree, #end, #flank, #heap, inherited, make, names, #prepare_on_receive_last, #trigger_on_error
Methods inherited from Node
#child_id, #cnodes, #cnodes_any?, #cnodes_empty?, #deref, #descendant_of?, #domain, #exid, #fei, #from, #h, #initialize, #lookup_tree, #lookup_value, #message_or_node_payload, #nid, #node_closed?, #node_ended?, #node_open?, #node_payload, #node_payload_ret, #node_status, #node_status_flavour, #on_error_parent, #parent, #payload, #payload_ret, #point, #reheap, #to_procedure_node, #tree
Constructor Details
This class inherits a constructor from Flor::Node
Instance Method Details
#add ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/flor/punit/c_iterator.rb', line 74 def add col = @node['col'] elts = ['elements'] fail Flor::FlorError.new( "cannot add branches to #{heap}", self ) unless elts tcol = Flor.type(col) x = if tcol == :object elts.inject(nil) { |r, e| next r if r t = Flor.type(e) t != :object ? t : r } else nil end fail Flor::FlorError.new("cannot add #{x} to object", self) \ if x if tcol == :array col.concat(elts) else # tcol == :object elts.each { |e| col.merge!(e) } end cnt = @node['cnt'] @node['cnt'] += elts.size pl = ['payload'] || node_payload.current elts .collect .with_index { |e, i| apply( @node['fun'], determine_iteration_args(col, cnt + i), tree[2], payload: Flor.dup(pl)) } .flatten(1) end |
#pre_execute ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/flor/punit/c_iterator.rb', line 12 def pre_execute @node['atts'] = [] @node['args'] = [] @node['col'] = nil reff_att_children unatt_unkeyed_children end |
#receive_last ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/flor/punit/c_iterator.rb', line 36 def receive_last t1 = tree[1] col = nil fun = nil refs = [] # @node['args'].each_with_index do |a, i| if ( ! fun) && Flor.is_func_tree?(a) fun = a elsif ( ! col) && Flor.is_collection?(a) col = a else tt = t1[i] refs << Flor.ref_to_path(tt) if Flor.is_ref_tree?(tt) end end # col ||= node_payload_ret fail Flor::FlorError.new("collection not given to #{heap.inspect}", self) \ unless Flor.is_collection?(col) return wrap('ret' => col) \ unless Flor.is_func_tree?(fun) @node['col'] = col @node['cnt'] = col.size @node['fun'] = fun @node['refs'] = refs col .collect .with_index { |e, i| apply(fun, determine_iteration_args(col, i), tree[2]) } .flatten(1) end |
#receive_non_att ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/flor/punit/c_iterator.rb', line 22 def receive_non_att if Flor.same_sub?(nid, from) @node['args'] << payload['ret'] super elsif @node['on_receive_nids'] && @node['on_receive_nids'][0] == from receive_from_receiver elsif @node['merging'] receive_from_merger else receive_from_branch end end |