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;
39 if nargin >= 3 && ~isempty(fork)
46 elseif model.isJavaNative()
48 if nargin >= 3 && ~isempty(fork)
49 self.obj = jline.lang.nodes.Join(model.obj, name, fork.obj);
51 self.obj = jline.lang.nodes.Join(model.obj, name);
53 self.index = model.obj.getNodeIndex(self.obj);
55 %
if ~exist(
'joinstrategy',
'var')
56 % joinstrategy = JoinStrategy.STD;
58 % setStrategy(joinstrategy);
63 function self = setStrategy(self,
class, strategy)
64 % SELF = SETSTRATEGY(CLASS, STRATEGY)
66 self.input.setStrategy(
class,strategy);
69 function self = setRequired(self,
class, njobs)
70 % SELF = SETREQUIRED(CLASS, NJOBS)
72 self.input.setRequired(
class,njobs);
75 function self = setProbRouting(self,
class, destination, probability)
76 % SELF = SETPROBROUTING(CLASS, DESTINATION, PROBABILITY)
78 setRouting(self,
class, RoutingStrategy.PROB, destination, probability);
81 function summary(self)
84 line_printf('\nNode: <strong>%s</strong>',self.getName);
85 for r=1:length(self.output.outputStrategy)
86 classes = self.model.getClasses();
87 line_printf('Routing %s: %s\n',
classes{r}.name, self.output.outputStrategy{r}{2});