runTask<S> static method

S runTask<S>(
  1. dynamic key,
  2. S run(
    1. EventQueue event
    ), {
  3. int channels = 1,
})

Implementation

static S runTask<S>(key, S Function(EventQueue event) run,
    {int channels = 1}) {
  final listKey = _TaskKeys(key, channels);

  final queue =
      _tempQueues.putIfAbsent(listKey, () => EventQueue(channels: channels));
  return run(queue)
    ..whenComplete(() {
      queue.runner.whenComplete(() {
        Timer(Duration(milliseconds: delayRemove.maxThan(0)), () {
          final cache = _tempQueues[listKey];
          if (!queue.actived && cache == queue) {
            _tempQueues.remove(listKey);
          }
        });
      });
    });
}