cl

concurrent-lock

Promise based lock object supporting semaphore.

Showing:

Popularity

Downloads/wk

2

GitHub Stars

4

Maintenance

Last Commit

3yrs ago

Contributors

0

Package

Dependencies

1

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

concurrent-lock

Promise based lock object supporting simultaneous access limit.

Install

npm install concurrent-lock

Usage

Create lock object with concurrent limit.

import Lock from 'concurrent-lock'

// concurrent access limit = 1
const simultaneous_limit = 2
const lock = new Lock(simultaneous_limit)

async somefunc() {
  await lock.lock()
  // ...some async proc...
  lock.unlock()

  // you can set timeout argument as millisec
  // Timeout error will be thrown if lock couldn't acquire within specified timeout millisec.
  await lock.lock(3000)
  // ...some async proc...
  lock.unlock()
}

Author

Yusuke Shibata

Licence

MIT

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial