2 % Task synchronization node
for fork-join models
4 % Combines parallel sibling tasks created by Fork
nodes, waiting until all arrive.
6 % Copyright (c) 2012-2026, Imperial College London
16 function self = Join(model, name, fork)
17 % JOIN Create a Join node instance
19 % @brief Creates a Join node
for synchronizing parallel tasks
20 % @param model Network model to add the join node to
21 % @param name String identifier
for the join node
22 % @param fork Optional Fork node
this join synchronizes with
23 % @
return self Join instance configured
for task synchronization
25 % The constructor creates a Join node with appropriate joiners,
26 % dispatchers, and service tunnels. If a fork parameter
is provided,
27 % the join
is associated with that specific fork node.
30 if model.isMatlabNative()
34 self.output = Dispatcher(
classes);
35 self.server = ServiceTunnel();
37 self.numberOfServers = Inf;
42 elseif model.isJavaNative()
44 if nargin >= 3 && ~isempty(fork)
45 self.obj = jline.lang.nodes.Join(model.obj, name, fork.obj);
47 self.obj = jline.lang.nodes.Join(model.obj, name);
49 self.index = model.obj.getNodeIndex(self.obj);
51 %
if ~exist(
'joinstrategy',
'var')
52 % joinstrategy = JoinStrategy.STD;
54 % setStrategy(joinstrategy);
59 function self = setStrategy(self,
class, strategy)
60 % SELF = SETSTRATEGY(CLASS, STRATEGY)
62 self.input.setStrategy(
class,strategy);
65 function self = setRequired(self,
class, njobs)
66 % SELF = SETREQUIRED(CLASS, NJOBS)
68 self.input.setRequired(
class,njobs);
71 function self = setProbRouting(self,
class, destination, probability)
72 % SELF = SETPROBROUTING(CLASS, DESTINATION, PROBABILITY)
74 setRouting(self,
class, RoutingStrategy.PROB, destination, probability);
77 function summary(self)
80 line_printf('\nNode: <strong>%s</strong>',self.getName);
81 for r=1:length(self.output.outputStrategy)
82 classes = self.model.getClasses();
83 line_printf('Routing %s: %s\n',
classes{r}.name, self.output.outputStrategy{r}{2});