Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/utilities/PriorityQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class PriorityQueue {

// options
this.maxJobs = 6;
this.schedulePerFrame = 6;

this.items = [];
this.callbacks = new Map();
Expand Down Expand Up @@ -84,10 +85,14 @@ class PriorityQueue {
const items = this.items;
const callbacks = this.callbacks;
const maxJobs = this.maxJobs;
const schedulePerFrame = this.schedulePerFrame;

let currJobs = this.currJobs;
while ( maxJobs > currJobs && items.length > 0 ) {
let scheduled = 0;
while ( maxJobs > currJobs && items.length > 0 && schedulePerFrame > scheduled ++ ) {

currJobs ++;
scheduled ++;
const item = items.pop();
const callback = callbacks.get( item );
callbacks.delete( item );
Expand Down