An open API service indexing awesome lists of open source software.

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.

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.