Skip to content

Commit

Permalink
Reverse findIndex for queuing tasks in waitForUnlock()
Browse files Browse the repository at this point in the history
  • Loading branch information
dmurvihill committed Feb 2, 2024
1 parent 981554f commit 4350d80
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Semaphore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ class Semaphore implements SemaphoreInterface {
}

function insertSorted<T extends Priority>(a: T[], v: T) {
const i = a.findIndex((other) => v.priority > other.priority);
const i = findIndexFromEnd(a, (other) => v.priority <= other.priority);
if (i === -1) {
a.push(v);
a.splice(0, 0, v);
} else {
a.splice(i, 0, v);
a.splice(i + 1, 0, v);
}
}

Expand Down

0 comments on commit 4350d80

Please sign in to comment.