tick static method

Future<void> tick()

A single simulation tick.

Takes the simulator through all actions within the next pending timestamp, and passes through all events and phases on the way.

If there are no timestamps pending to execute, nothing will execute.

Implementation

static Future<void> tick() async {
  if (_injectedActions.isNotEmpty) {
    // case 1 : ( the usual Rohd case )
    // The previous delta cycle did NOT do
    // 'registerAction( _currentTimeStamp );'.
    // In that case, _pendingTimestamps[_currentTimestamp] is null so we will
    // add a new empty list, which will trigger a new delta cycle.
    //
    // case 2 :
    // The previous delta cycle DID do 'registerAction( _currentTimestamp );'.
    // In that case, there is *already* another tick scheduled for
    // _currentTimestamp, and the injected actions will get called in
    //  the normal way.
    //
    // Either way, the end result is that a whole new tick gets scheduled for
    // _currentTimestamp and any outstanding injected actions get executed.

    // ignore: unnecessary_lambdas
    _pendingTimestamps.putIfAbsent(_currentTimestamp, () => ListQueue());
  }

  // the main event loop
  if (_updateTimeStamp()) {
    _preTick();
    await _mainTick();
    _clkStable();
    await _outOfTick();
  }
}