registerAction static method

void registerAction(
  1. int timestamp,
  2. dynamic action()
)

Registers an abritrary action to be executed at timestamp time.

The action, if it returns a Future, will be awaited.

Implementation

static void registerAction(int timestamp, dynamic Function() action) {
  if (timestamp < _currentTimestamp) {
    throw SimulatorException('Cannot add timestamp "$timestamp" in the past.'
        ' Current time is ${Simulator.time}.'
        ' Did you mean to include a call to Simulator.reset()?'
        ' If this is hit in a series of unit tests, see the user guide'
        ' for tips:'
        ' https://intel.github.io/rohd-website/docs/unit-test/');
  }
  if (!_pendingTimestamps.containsKey(timestamp)) {
    _pendingTimestamps[timestamp] = ListQueue();
  }
  _pendingTimestamps[timestamp]!.add(action);
}