advance method

void advance(
  1. Duration by
)

Moves the clock forward by by, firing due timers as it goes.

Implementation

void advance(Duration by) {
  final target = _now + by;
  while (true) {
    _FakeTimer? next;
    for (final t in _timers) {
      if (t.due > target) continue;
      if (next == null || t.due < next.due || (t.due == next.due && t.order < next.order)) next = t;
    }
    if (next == null) break;
    _timers.remove(next);
    _now = next.due;
    next.fire();
  }
  _now = target;
}