$startTicking static method

Future<void> $startTicking(
  1. Node node,
  2. NodeStorage storage,
  3. PrecisionStopwatch wallClock
)

Implementation

static Future<void> $startTicking(
    Node node, NodeStorage storage, PrecisionStopwatch wallClock) async {
  if (node is Ticked) {
    Ticked t = node as Ticked;
    Future.delayed(Duration.zero, () async {
      node.logger
          .verbose("Ticker started at +${wallClock.getMilliseconds()}ms");
      double time = wallClock.getMilliseconds();
      int ticks = 0;
      while (node.$isActive &&
          (node is Stateful && (node as Lifecycle).$isRunning)) {
        double was = time;
        time = wallClock.getMilliseconds();
        await Future.delayed(await t.onTick(time, time - was, ticks++));
      }

      node.logger.verbose("Ticker Shutdown");
    });
  }
}