Fix task scheduling

This commit is contained in:
2020-05-26 11:54:50 +03:00
parent 09e989a8a1
commit a358fe743e
3 changed files with 22 additions and 11 deletions

View File

@ -1,6 +1,8 @@
import { Args } from './Args';
import { uniqId } from '../utils';
import { ResourcesInterface } from '../Core/Resources';
import { ProductionQueue } from '../Core/ProductionQueue';
import { getProductionQueue } from '../Task/TaskMap';
export type TaskId = string;
@ -40,10 +42,18 @@ export interface TaskProvider {
setTasks(tasks: TaskList): void;
}
export interface TaskMatcher {
(task: Task): boolean;
}
export interface TaskTransformer {
(task: Task): Task;
}
export function isInQueue(queue: ProductionQueue): TaskMatcher {
return (task: Task) => getProductionQueue(task.name) === queue;
}
export function withTime(ts: number): TaskTransformer {
return (task: Task) => new Task(task.id, ts, task.name, task.args);
}