Class: Flor::Pro::Concurrence

Inherits:
Flor::Procedure show all
Includes:
ReceiveAndMerge
Defined in:
lib/flor/punit/concurrence.rb

Constant Summary

Constants inherited from Flor::Procedure

Flor::Procedure::RVARS, Flor::Procedure::TRUE_ATTS

Instance Attribute Summary

Attributes inherited from Node

#message

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

#addObject



338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
# 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

#pre_executeObject



301
302
303
304
305
306
# File 'lib/flor/punit/concurrence.rb', line 301

def pre_execute

  @node['atts'] = []

  pre_execute_rewrite
end

#receive_last_attObject



308
309
310
311
312
313
314
315
316
317
318
319
320
# 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

#receive_non_attObject



322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
# 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