1function sync = refreshSync(self)
5local = self.getNumberOfNodes+1;
8emptystate = cellzeros(sn.nnodes,1,0,0);
9if any(sn.isstatedep(:))
10 rtmask = self.sn.rtfun(emptystate, emptystate);
12 rtmask = ceil(self.sn.rt);
17 if sn.isstation(ind) && sn.phases(sn.nodeToStation(ind),r)> 1
19 sync{end+1,1} =
struct(
'active',cell(1),
'passive',cell(1));
20 sync{end,1}.active{1} = Event(EventType.PHASE, ind, r);
21 sync{end,1}.passive{1} = Event(EventType.LOCAL, local, r, 1.0);
23 if sn.isstation(ind) && isfield(sn,
'impatienceClass') && ~isempty(sn.impatienceClass) ...
24 && sn.impatienceClass(sn.nodeToStation(ind),r) == ImpatienceType.RENEGING ...
25 && sn.impatienceType(sn.nodeToStation(ind),r) == ProcessType.EXP
26 % Reneging action (exponential patience): a waiting class-r job
27 % abandons the queue at a memoryless per-job rate; the job leaves
28 % the system (passive LOCAL, mirroring the phase-change action).
29 sync{end+1,1} =
struct(
'active',cell(1),
'passive',cell(1));
30 sync{end,1}.active{1} = Event(EventType.RENEGE, ind, r);
31 sync{end,1}.passive{1} = Event(EventType.LOCAL, local, r, 1.0);
33 if sn.isstation(ind) && isfield(sn,
'retrialProc') && ~isempty(sn.retrialProc) ...
34 && ~isempty(sn.retrialProc{sn.nodeToStation(ind),r}) ...
35 && sn.retrialType(sn.nodeToStation(ind),r) == ProcessType.EXP
36 % see _kb/04-networkstruct.md (refreshGlobalSync/refreshSync)
for rationale
37 sync{end+1,1} =
struct(
'active',cell(1),
'passive',cell(1));
38 sync{end,1}.active{1} = Event(EventType.RETRY, ind, r);
39 sync{end,1}.passive{1} = Event(EventType.LOCAL, local, r, 1.0);
41 if sn.isstation(ind) && r == 1 && isfield(sn,
'hasbreakdown') && ~isempty(sn.hasbreakdown) ...
42 && numel(sn.hasbreakdown) >= ind && sn.hasbreakdown(ind) == 1
43 % Server failure and repair actions. Both are properties of the
44 % SERVER, not of a
class, so exactly one pair
is emitted per station
45 % (guarded on r == 1) rather than one pair per
class. Like the
46 % phase-change action they move no job, so the passive half
is LOCAL.
47 sync{end+1,1} =
struct(
'active',cell(1),
'passive',cell(1));
48 sync{end,1}.active{1} = Event(EventType.FAILURE, ind, r);
49 sync{end,1}.passive{1} = Event(EventType.LOCAL, local, r, 1.0);
50 sync{end+1,1} =
struct(
'active',cell(1),
'passive',cell(1));
51 sync{end,1}.active{1} = Event(EventType.REPAIR, ind, r);
52 sync{end,1}.passive{1} = Event(EventType.LOCAL, local, r, 1.0);
54 if sn.isstation(ind) && sn.sched(sn.nodeToStation(ind)) == SchedStrategy.POLLING
55 % see _kb/04-networkstruct.md (refreshGlobalSync/refreshSync)
for rationale
56 pinfoSync = State.pollingInfo(sn, ind);
57 if ~isempty(pinfoSync) && pinfoSync.hasSw(r)
58 sync{end+1,1} =
struct(
'active',cell(1),
'passive',cell(1));
59 sync{end,1}.active{1} = Event(EventType.SWITCH, ind, r);
60 sync{end,1}.passive{1} = Event(EventType.LOCAL, local, r, 1.0);
64 if sn.nodetype(ind) == NodeType.Cache
65 if ~isnan(sn.nodeparam{ind}.pread{r}) %
class can read
66 sync{end+1,1}.active{1} = Event(EventType.READ, ind, r);
67 sync{end,1}.passive{1} = Event(EventType.READ, local, r, 1.0);
69 elseif sn.nodetype(ind) == NodeType.Transition
70 for m=1:sn.nodeparam{ind}.nmodes
72 sync{end+1,1}.active{1} = Event(EventType.PHASE, ind, m);
73 sync{end,1}.passive{1} = Event(EventType.LOCAL, local, m, 1.0);
76 if sn.nodetype(ind) == NodeType.Fork
77 % Stateful Fork
nodes (FJ-augmented copies)
do not emit
78 % departure syncs: the atomic multi-branch emission
is
79 % handled by the fork firing synchronizations (sn.fjsync)
82 isf = sn.nodeToStateful(ind);
85 jsf = sn.nodeToStateful(jnd);
87 p = rtmask((isf-1)*nclasses+r,(jsf-1)*nclasses+s);
89 new_sync = struct('active',cell(1),'passive',cell(1));
90 new_sync.active{1} = Event(EventType.DEP, ind, r);
91 switch sn.routing(ind,s)
92 case {RoutingStrategy.RROBIN, RoutingStrategy.WRROBIN, RoutingStrategy.JSQ, RoutingStrategy.RL, RoutingStrategy.SQ}
93 new_sync.passive{1} = Event(EventType.ARV, jnd, s, @(state_before, state_after) at(self.sn.rtfun(state_before, state_after), (isf-1)*nclasses+r, (jsf-1)*nclasses+s));
95 new_sync.passive{1} = Event(EventType.ARV, jnd, s, sn.rt((isf-1)*nclasses+r, (jsf-1)*nclasses+s));
97 sync{end+1,1} = new_sync;
105if ~isempty(self.sn) %&& isprop(self.sn,
'nvars')