@push.rocks/taskbuffer 3.0.14 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist_bundle/bundle.js +26 -20
- package/dist_bundle/bundle.js.map +2 -2
- package/dist_ts/00_commitinfo_data.js +2 -2
- package/dist_ts/taskbuffer.classes.task.d.ts +4 -4
- package/dist_ts/taskbuffer.classes.task.js +20 -17
- package/dist_ts/taskbuffer.classes.taskmanager.d.ts +5 -5
- package/dist_ts/taskbuffer.classes.taskmanager.js +13 -7
- package/package.json +1 -1
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/taskbuffer.classes.task.ts +33 -20
- package/ts/taskbuffer.classes.taskmanager.ts +14 -6
package/dist_bundle/bundle.js
CHANGED
|
@@ -5926,22 +5926,23 @@ var logger = new dist_ts_exports9.ConsoleLog();
|
|
|
5926
5926
|
// ts/taskbuffer.classes.task.ts
|
|
5927
5927
|
var _Task = class {
|
|
5928
5928
|
constructor(optionsArg) {
|
|
5929
|
+
// Add a list to store the blocking tasks
|
|
5930
|
+
this.blockingTasks = [];
|
|
5929
5931
|
this.running = false;
|
|
5930
5932
|
this.bufferRunner = new BufferRunner(this);
|
|
5931
5933
|
this.cycleCounter = new CycleCounter(this);
|
|
5932
|
-
this.idle = true;
|
|
5933
|
-
this._state = "ready";
|
|
5934
5934
|
this.taskFunction = optionsArg.taskFunction;
|
|
5935
5935
|
this.preTask = optionsArg.preTask;
|
|
5936
5936
|
this.afterTask = optionsArg.afterTask;
|
|
5937
|
-
this.idle = !this.running;
|
|
5938
5937
|
this.buffered = optionsArg.buffered;
|
|
5939
5938
|
this.bufferMax = optionsArg.bufferMax;
|
|
5940
5939
|
this.execDelay = optionsArg.execDelay;
|
|
5941
5940
|
this.name = optionsArg.name;
|
|
5942
5941
|
this.taskSetup = optionsArg.taskSetup;
|
|
5942
|
+
this.finished = new Promise((resolve) => {
|
|
5943
|
+
this.resolveFinished = resolve;
|
|
5944
|
+
});
|
|
5943
5945
|
}
|
|
5944
|
-
// STATIC
|
|
5945
5946
|
static extractTask(preOrAfterTaskArg) {
|
|
5946
5947
|
switch (true) {
|
|
5947
5948
|
case !preOrAfterTaskArg:
|
|
@@ -5965,6 +5966,9 @@ var _Task = class {
|
|
|
5965
5966
|
}
|
|
5966
5967
|
return result;
|
|
5967
5968
|
}
|
|
5969
|
+
get idle() {
|
|
5970
|
+
return !this.running;
|
|
5971
|
+
}
|
|
5968
5972
|
trigger(x) {
|
|
5969
5973
|
if (this.buffered) {
|
|
5970
5974
|
return this.triggerBuffered(x);
|
|
@@ -5978,16 +5982,6 @@ var _Task = class {
|
|
|
5978
5982
|
triggerBuffered(x) {
|
|
5979
5983
|
return this.bufferRunner.trigger(x);
|
|
5980
5984
|
}
|
|
5981
|
-
get state() {
|
|
5982
|
-
return this._state;
|
|
5983
|
-
}
|
|
5984
|
-
set state(stateArg) {
|
|
5985
|
-
if (stateArg === "locked") {
|
|
5986
|
-
this._state = "locked";
|
|
5987
|
-
} else {
|
|
5988
|
-
logger.log("error", `state type ${stateArg} could not be set`);
|
|
5989
|
-
}
|
|
5990
|
-
}
|
|
5991
5985
|
};
|
|
5992
5986
|
var Task = _Task;
|
|
5993
5987
|
Task.emptyTaskFunction = function(x) {
|
|
@@ -6005,6 +5999,9 @@ Task.isTask = (taskArg) => {
|
|
|
6005
5999
|
Task.runTask = async (taskArg, optionsArg) => {
|
|
6006
6000
|
const taskToRun = _Task.extractTask(taskArg);
|
|
6007
6001
|
const done = dist_ts_exports.defer();
|
|
6002
|
+
for (const task of taskToRun.blockingTasks) {
|
|
6003
|
+
await task.finished;
|
|
6004
|
+
}
|
|
6008
6005
|
if (!taskToRun.setupValue && taskToRun.taskSetup) {
|
|
6009
6006
|
taskToRun.setupValue = await taskToRun.taskSetup();
|
|
6010
6007
|
}
|
|
@@ -6014,6 +6011,10 @@ Task.runTask = async (taskArg, optionsArg) => {
|
|
|
6014
6011
|
taskToRun.running = true;
|
|
6015
6012
|
done.promise.then(async () => {
|
|
6016
6013
|
taskToRun.running = false;
|
|
6014
|
+
taskToRun.resolveFinished();
|
|
6015
|
+
taskToRun.finished = new Promise((resolve) => {
|
|
6016
|
+
taskToRun.resolveFinished = resolve;
|
|
6017
|
+
});
|
|
6017
6018
|
});
|
|
6018
6019
|
const options = {
|
|
6019
6020
|
...{ x: void 0, touchedTasksArray: [] },
|
|
@@ -6129,14 +6130,14 @@ var AbstractDistributedCoordinator = class {
|
|
|
6129
6130
|
|
|
6130
6131
|
// ts/taskbuffer.classes.taskmanager.ts
|
|
6131
6132
|
var TaskManager = class {
|
|
6132
|
-
constructor(
|
|
6133
|
+
constructor(optionsArg = {}) {
|
|
6133
6134
|
this.randomId = isounique2.uni();
|
|
6134
6135
|
this.taskMap = new dist_ts_exports5.ObjectMap();
|
|
6135
6136
|
this.cronJobManager = new dist_ts_exports6.CronManager();
|
|
6136
6137
|
this.options = {
|
|
6137
6138
|
distributedCoordinator: null
|
|
6138
6139
|
};
|
|
6139
|
-
this.options = Object.assign(this.options,
|
|
6140
|
+
this.options = Object.assign(this.options, optionsArg);
|
|
6140
6141
|
}
|
|
6141
6142
|
/**
|
|
6142
6143
|
* checks if a task is already present
|
|
@@ -6238,10 +6239,15 @@ var TaskManager = class {
|
|
|
6238
6239
|
await this.descheduleTaskByName(task.name);
|
|
6239
6240
|
}
|
|
6240
6241
|
/**
|
|
6241
|
-
|
|
6242
|
-
|
|
6243
|
-
|
|
6244
|
-
|
|
6242
|
+
* returns the schedule of a specific task
|
|
6243
|
+
* @param taskNameArg
|
|
6244
|
+
*/
|
|
6245
|
+
getScheduleForTaskName(taskNameArg) {
|
|
6246
|
+
const task = this.getTaskByName(taskNameArg);
|
|
6247
|
+
if (!task || !task.cronJob) {
|
|
6248
|
+
return null;
|
|
6249
|
+
}
|
|
6250
|
+
return task.cronJob.cronExpression;
|
|
6245
6251
|
}
|
|
6246
6252
|
/**
|
|
6247
6253
|
* starts the taskmanager
|