runTaskQueue method

void runTaskQueue()

This function controls the processing of tasks. It schedules tasks when there is idle time at the end of a simulation step.

Implementation

void runTaskQueue() {//deadline
  final tasks = this.tasks;

  while ( stopwatch.elapsed < options && tasks.isNotEmpty ) {
    final task = tasks[ 0 ];
    task.execute();
    tasks.removeAt(0);
  }

  if ( tasks.isNotEmpty ) {
    stopwatch.reset();
    stopwatch.start();
    taskHandle = Future.delayed(Duration.zero, _handler).timeout(options,onTimeout: (){stopwatch.stop();});//requestIdleCallback( _handler, options );
    _active = true;
  }
  else {
    taskHandle = null;
    _active = false;
    stopwatch.stop();
  }
}