federer
Version:
Experiments in asynchronous federated learning and decentralized learning
27 lines • 1.11 kB
TypeScript
/**
* Abstraction for running asynchronous, locked, prioritized tasks.
*
* Tasks are *asynchronous*: they should return a `Promise<void>`.
*
* The tasks are *locked*: a lock is acquired before they are executed. They are
* still executed asynchronously, but not concurrently with each other. However,
* they can execute concurrently with unrelated `Promise`s.
*
* Finally, the tasks are *prioritized*: only the task with the highest priority
* is executed. Registering a task invalidates all not-yet-executed tasks with
* lower priorities.
*/
export declare class PrioritizedLockedTaskRunner {
private readonly lock;
private highestPriority;
/**
* Register a task to run when the lock is available, if not invalidated by a
* higher-priority task.
*
* @param priority Priority of the task. All registered but not-yet-executed
* tasks with lower priority will be invalidated.
* @param task Callback containing the task to run
*/
run<T>(priority: number, task: () => T | Promise<T>): Promise<T>;
}
//# sourceMappingURL=PrioritizedLockedTaskRunner.d.ts.map