Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cfware/p-mutex
Promise based mutex
https://github.com/cfware/p-mutex
Last synced: 29 days ago
JSON representation
Promise based mutex
- Host: GitHub
- URL: https://github.com/cfware/p-mutex
- Owner: cfware
- License: mit
- Created: 2017-12-02T08:14:55.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-11-06T15:13:57.000Z (about 4 years ago)
- Last Synced: 2024-11-12T09:02:49.751Z (about 1 month ago)
- Language: JavaScript
- Size: 110 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# @cfware/p-mutex [![NPM Version][npm-image]][npm-url]
Promise based mutex
## Usage
```js
import {PMutex} from '@cfware/p-mutex';/* PMutex ignores any parameters. */
const mutex = new PMutex();export const serializedAsyncAction = async () => {
const lock = await mutex.lock();/* Do some stuff, release the lock eventually. */
setTimeout(() => lock.release(), 10);
}
```This module does not provide timeout functionality. `lock.release()` must be
called or the `mutex.lock()` will never resolve again.[npm-image]: https://img.shields.io/npm/v/@cfware/p-mutex.svg
[npm-url]: https://npmjs.org/package/@cfware/p-mutex