queue-scheduler icon indicating copy to clipboard operation
queue-scheduler copied to clipboard

Support iterable

Open dinoboff opened this issue 6 years ago • 0 comments

Instead of calling next tick, an iterable task would just yield. The task should either return the last value, an array of all the values or void.

/**
 * Maintains a set of queues, each with their own QueueScheduler to schedule
 * task execution.
 */
class Scheduler {
  addQueue(name: string, scheduler: QueueScheduler): void;

  /**
   * Schedule a task on a named queue. The queue must already exist via a call
   * to `addQueue`.
   *
   * TODO: Accept a CancelToken
   */
  scheduleTask<T>(queueName: string, task: TaskFunction<T>): Promise<T>;
  scheduleTask<T>(queueName: string, task: IterableIterator<T>): Promise<T>;
  scheduleTask<T>(queueName: string, task: AsyncIterableIterator<T>): Promise<T>;
}

dinoboff avatar May 04 '18 10:05 dinoboff