|
@@ -12,18 +12,25 @@ class PriorityQueue {
|
|
this.autoUpdate = true;
|
|
this.autoUpdate = true;
|
|
|
|
|
|
this.priorityCallback = () => {
|
|
this.priorityCallback = () => {
|
|
|
|
+
|
|
throw new Error( 'PriorityQueue: PriorityCallback function not defined.' );
|
|
throw new Error( 'PriorityQueue: PriorityCallback function not defined.' );
|
|
|
|
+
|
|
};
|
|
};
|
|
|
|
|
|
// Customizable scheduling callback. Default using requestAnimationFrame()
|
|
// Customizable scheduling callback. Default using requestAnimationFrame()
|
|
this.schedulingCallback = func => {
|
|
this.schedulingCallback = func => {
|
|
|
|
+
|
|
requestAnimationFrame( func );
|
|
requestAnimationFrame( func );
|
|
|
|
+
|
|
};
|
|
};
|
|
|
|
|
|
- this._runjobs = ()=>{
|
|
|
|
|
|
+ this._runjobs = () => {
|
|
|
|
+
|
|
this.tryRunJobs();
|
|
this.tryRunJobs();
|
|
this.scheduled = false;
|
|
this.scheduled = false;
|
|
|
|
+
|
|
};
|
|
};
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
sort() {
|
|
sort() {
|
|
@@ -114,10 +121,13 @@ class PriorityQueue {
|
|
}
|
|
}
|
|
|
|
|
|
scheduleJobRun() {
|
|
scheduleJobRun() {
|
|
- if ( !this.scheduled ){
|
|
|
|
|
|
+
|
|
|
|
+ if ( ! this.scheduled ){
|
|
|
|
+
|
|
this.schedulingCallback( this._runjobs );
|
|
this.schedulingCallback( this._runjobs );
|
|
|
|
|
|
this.scheduled = true;
|
|
this.scheduled = true;
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|