https://github.com/seangenabe/mutex
Simple async-await mutex.
https://github.com/seangenabe/mutex
mutex semaphore
Last synced: 7 months ago
JSON representation
Simple async-await mutex.
- Host: GitHub
- URL: https://github.com/seangenabe/mutex
- Owner: seangenabe
- License: mit
- Created: 2018-01-31T15:36:13.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-05T14:08:18.000Z (over 6 years ago)
- Last Synced: 2025-03-18T05:56:58.075Z (7 months ago)
- Topics: mutex, semaphore
- Language: TypeScript
- Size: 7.81 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Funding: .github/FUNDING.yml
- License: license.md
Awesome Lists containing this project
README
# Mutex
Simple async-await mutex.
## Usage
```typescript
import { Mutex } from '@seangenabe/mutex'const mutex = new Mutex()
;(async () => {
const release = await mutex.wait()
// ...
release()
})()```
### mutex.wait(): Promise<() => void>
Returns: `Promise<() => void>`
Waits for other claims on this mutex, then resolves with a function that can be called to release the claim on this mutex.