From 72ff8f07aab0d018edf4c6b3f15d9e5d8ff1255a Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sat, 28 Nov 2020 00:22:27 +0300 Subject: [PATCH] added task start/stop times... Signed-off-by: Alex A. Naanou --- package.json | 2 +- runner.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index b55ecaa..121dcad 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ig-types", - "version": "5.0.20", + "version": "5.0.21", "description": "Generic JavaScript types and type extensions...", "main": "main.js", "scripts": { diff --git a/runner.js b/runner.js index b7a9890..1a3233a 100644 --- a/runner.js +++ b/runner.js @@ -439,6 +439,17 @@ object.Constructor('TaskManager', Array, events.EventMixin('flat', { __task_ticket__: TaskTicket, __task_mixin__: TaskMixin, + // settings... + // + // if true start/end times will be set on the task: + // .time_started + // .time_ended + record_times: true, + + // if true the task will be started sync before .Task(..) is returns.. + // + // NOTE: this is not recommended as the default as this can block the + // manager... sync_start: false, @@ -616,6 +627,8 @@ object.Constructor('TaskManager', Array, events.EventMixin('flat', { // handle task manager state... var cleanup = function(evt){ return function(res){ + that.record_times + && (handler.time_ended = Date.now()) that.splice(that.indexOf(handler), 1) that.trigger(evt, task, res) that.length == 0 @@ -623,6 +636,9 @@ object.Constructor('TaskManager', Array, events.EventMixin('flat', { handler .then(cleanup('done'), cleanup('error')) + this.record_times + && (handler.time_started = Date.now()) + // start... var start = function(){ run ?