Skip to content

Commit f66892d

Browse files
committed
Call _updateMaxLevel() before reacting reactions
`_updateMaxLevel()` should be called carefully cause it has a key role of managing the execution. And it is not easy to optimize the call of the function. So let's call it before executing reactions every time. This is brute-force way but we can optimize it later.
1 parent 688c9ae commit f66892d

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

src/core/federation.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,6 +1408,7 @@ export class FederatedApp extends App {
14081408
* @returns Whether every reactions at this tag are executed.
14091409
*/
14101410
protected _react(): boolean {
1411+
this._updateMaxLevel();
14111412
let r: Reaction<Variable[]>;
14121413
while (this._reactionQ.size() > 0) {
14131414
r = this._reactionQ.peek();
@@ -1558,7 +1559,6 @@ export class FederatedApp extends App {
15581559
Log.debug(this, () => {
15591560
return "In update_last_known_status_on_input ports.";
15601561
});
1561-
let notify = false;
15621562
this.networkReceivers.forEach(
15631563
(networkReceiver: NetworkReceiver<unknown>, portID: number) => {
15641564
// This is called when a TAG is received.
@@ -1575,13 +1575,9 @@ export class FederatedApp extends App {
15751575
);
15761576
});
15771577
networkReceiver.lastKnownStatusTag = tag;
1578-
notify = true;
15791578
}
15801579
}
15811580
);
1582-
if (notify) {
1583-
this._updateMaxLevel();
1584-
}
15851581
}
15861582

15871583
/**
@@ -1896,8 +1892,6 @@ export class FederatedApp extends App {
18961892

18971893
this._enqueuePortAbsentReactions();
18981894

1899-
this._updateMaxLevel();
1900-
19011895
this.rtiClient.on("connected", () => {
19021896
this.rtiClient.sendNeighborStructure(
19031897
this.upstreamFedIDs,
@@ -2018,7 +2012,6 @@ export class FederatedApp extends App {
20182012
// wake up _next, in case it was blocked by the old time advance grant
20192013
this.greatestTimeAdvanceGrant = ptag;
20202014
this._isLastTAGProvisional = true;
2021-
this._updateMaxLevel();
20222015
this._requestImmediateInvocationOfNext();
20232016
});
20242017

src/core/reactor.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2350,14 +2350,14 @@ export class App extends Reactor {
23502350
nextEvent = this._eventQ.peek();
23512351
}
23522352

2353-
// End of this execution step. Perform cleanup.
2354-
while (this._reactorsToRemove.length > 0) {
2355-
// const r = this._reactorsToRemove.pop();
2356-
// FIXME: doing this for the entire model at the end of execution
2357-
// could be a pretty significant performance hit, so we probably
2358-
// don't want to do this
2359-
// r?._unplug() FIXME: visibility
2360-
}
2353+
// // End of this execution step. Perform cleanup.
2354+
// while (this._reactorsToRemove.length > 0) {
2355+
// // const r = this._reactorsToRemove.pop();
2356+
// // FIXME: doing this for the entire model at the end of execution
2357+
// // could be a pretty significant performance hit, so we probably
2358+
// // don't want to do this
2359+
// // r?._unplug() FIXME: visibility
2360+
// }
23612361

23622362
// Peek at the event queue to see whether we can process the next event
23632363
// or should give control back to the JS event loop.

0 commit comments

Comments
 (0)