added autostop...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-11-07 03:30:03 +03:00
parent b048a0229f
commit 9193b90f7e
2 changed files with 11 additions and 7 deletions

View File

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

View File

@ -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 },