added task start/stop times...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-11-28 00:22:27 +03:00
parent 5b88d49dbd
commit 72ff8f07aa
2 changed files with 17 additions and 1 deletions

View File

@ -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": {

View File

@ -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 ?