jcue - javascript job-queueing engine
// create a new jcue object with
jcue.clock = 100;
// put job-queue to jcue
jcue.put( function(){ ... } );
// And, jcue is going to work for jobs automatically... :)
ytnobody
var jcue = { timer: -1 }; | |
jcue.version = 0.01; | |
jcue.queue = new Array(); | |
jcue.work = function(){ | |
if ( typeof( this.queue ) != 'undefined' ) { | |
while ( this.queue.length > 0 ) { | |
q = this.queue.shift(); | |
q(); | |
} | |
jcue.stop(); | |
} | |
}; | |
jcue.run = function(){ | |
if ( this.timer == -1 ) { | |
var self = this; | |
this.timer = setInterval( function(){ self.work() }, self.clock ); | |
} | |
}; | |
jcue.stop = function(){ | |
clearInterval( this.timer ); | |
this.timer = -1; | |
}; | |
jcue.put = function( f ){ | |
this.queue.push( f ); | |
this.run(); | |
}; | |
/* | |
=head1 NAME | |
jcue - javascript job-queueing engine | |
=head1 SYNOPSIS | |
// create a new jcue object with | |
jcue.clock = 100; | |
// put job-queue to jcue | |
jcue.put( function(){ ... } ); | |
// And, jcue is going to work for jobs automatically... :) | |
=head1 AUTHOR | |
ytnobody | |
=cut | |
*/ |