Skip to content

Commit

Permalink
Merge pull request #323 from tulios/improve-lock-performance
Browse files Browse the repository at this point in the history
Process a fixed number of lock releases per iteration on lock#release
  • Loading branch information
tulios committed Apr 1, 2019
1 parent d6b88a5 commit 4ede581
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/utils/lock.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ module.exports = class Lock {

async release() {
this[PRIVATE.LOCKED] = false
const waitingForLock = Array.from(this[PRIVATE.WAITING])
return Promise.all(waitingForLock.map(acquireLock => acquireLock()))
const waitingLock = this[PRIVATE.WAITING].values().next().value

if (waitingLock) {
return waitingLock()
}
}
}

0 comments on commit 4ede581

Please sign in to comment.