async-promise
Version:
Asynchronous coordination primitives for JavaScript and TypeScript
38 lines (37 loc) • 1.2 kB
TypeScript
export declare class Task {
private _onexecute;
private _oncancel;
constructor(onexecute: () => void, oncancel?: (reason: any) => void);
execute(): void;
cancel(reason?: any): void;
}
export declare enum TaskSchedulerPriority {
none = -1,
background = 0,
send = 1,
}
export declare class TaskScheduler {
private static _default;
private _state;
private _channel;
private _handle;
private _backgroundQueue;
private _sendQueue;
private _marker;
private _marked;
private _ontick;
constructor();
static default: TaskScheduler;
max: TaskSchedulerPriority;
enqueue(priority: TaskSchedulerPriority, onexecute: () => void, oncancel?: (reason: any) => void): Task;
delay(msec: number, onexecute: () => void, oncancel?: (reason: any) => void): Task;
private requestTick();
private resetTick();
private tick();
private getQueue(priority);
private dequeue();
private onexecute(priority, node, onexecute);
private oncancel(priority, node, oncancel, reason);
private ondelayexecute(handle, onexecute);
private ondelaycancel(handle, oncancel, reason);
}