diff --git a/package.json b/package.json index 60d3f72..c9f9f43 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ig-types", - "version": "3.3.0", + "version": "3.3.1", "description": "Generic JavaScript types and type extensions...", "main": "main.js", "scripts": { diff --git a/runner.js b/runner.js index 36ccb16..32a3270 100644 --- a/runner.js +++ b/runner.js @@ -29,6 +29,7 @@ module.Queue = object.Constructor('Queue', Array, { },{ pool_size: 8, poling_delay: 200, + autostop: false, __state: null, get state(){ @@ -134,7 +135,7 @@ module.Queue = object.Constructor('Queue', Array, { } else { this.trigger('taskCompleted', task, res) } } - // pole on empty queue... + // empty queue -> pole or stop... // // NOTE: we endup here in two cases: // - the pool is full @@ -144,11 +145,14 @@ module.Queue = object.Constructor('Queue', Array, { // // XXX will this be collected by the GC if it is polling??? if(this.length == 0 - && this.state == 'running' - && this.poling_delay){ - setTimeout( - this._run.bind(this), - this.poling_delay || 200) } + && this.state == 'running'){ + this.autostop ? + this.stop() + // pole... + : (this.poling_delay + && setTimeout( + this._run.bind(this), + this.poling_delay || 200)) } return this },