queue-scheduler
queue-scheduler copied to clipboard
Support iterable
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>;
}