@@ -2307,18 +2307,19 @@ export class App extends Reactor {
23072307 }
23082308
23092309 /**
2310- *
2311- * @param nextEvent
2312- */
2313- protected _popEvents ( nextEvent ?: TaggedEvent < unknown > ) : void {
2314- // Start processing events. Execute all reactions that are triggered
2315- // at the current tag in topological order. After that, if the next
2316- // event on the event queue has the same time (but a greater
2317- // microstep), repeat. This prevents JS event loop from gaining
2318- // control and imposing overhead. Asynchronous activity therefore
2319- // might get blocked, but since the results of such activities are
2320- // typically reported via physical actions, the tags of the
2321- // resulting events would be in the future, anyway.
2310+ * Pop all events from event_q with timestamp equal to current tag,
2311+ * extract all the reactions triggered by these events, and stick them
2312+ * into the reaction queue.
2313+ */
2314+ private _popEvents ( ) : void {
2315+ // Execute all reactions that are triggered at the current tag
2316+ // in topological order. After that, if the next event on the event queue
2317+ // has the same time (but a greater microstep), repeat. This prevents
2318+ // JS event loop from gaining control and imposing overhead. Asynchronous
2319+ // activity therefore might get blocked, but since the results of such
2320+ // activities are typically reported via physical actions, the tags of
2321+ // the resulting events would be in the future, anyway.
2322+ let nextEvent = this . _eventQ . peek ( ) ;
23222323 do {
23232324 // Keep popping the event queue until the next event has a different tag.
23242325 while ( nextEvent ?. tag . isSimultaneousWith ( this . _currentTag ) ?? false ) {
@@ -2413,8 +2414,8 @@ export class App extends Reactor {
24132414 // enqueue portAbsentReactions
24142415 this . _enqueuePortAbsentReactions ( ) ;
24152416 }
2416-
2417- this . _popEvents ( nextEvent ) ;
2417+ // Start processing events.
2418+ this . _popEvents ( ) ;
24182419
24192420 // React to all the events loaded onto the reaction queue.
24202421 this . _isDone = this . _react ( ) ;
0 commit comments