Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/117/mutex
A mutex implementation for Deno that supports async/await.
https://github.com/117/mutex
async await deno lock mutex
Last synced: about 1 month ago
JSON representation
A mutex implementation for Deno that supports async/await.
- Host: GitHub
- URL: https://github.com/117/mutex
- Owner: 117
- License: mit
- Created: 2024-08-11T04:54:22.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-08-11T05:37:46.000Z (5 months ago)
- Last Synced: 2024-10-14T08:20:56.156Z (2 months ago)
- Topics: async, await, deno, lock, mutex
- Language: TypeScript
- Homepage: https://jsr.io/@117/mutex
- Size: 10.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# mutex
![version](https://img.shields.io/jsr/v/%40117/mutex?style=flat-square&color=%23ff51bc&label=version)
![status](https://img.shields.io/github/actions/workflow/status/117/mutex/deploy.yml?style=flat-square)A mutex implementation for Deno that supports async/await.
## Contents
- [Features](#features)
- [Install](#install)
- [Example](#example)
- [Contributing](#contributing)## Features
- [x] Simple and lightweight.
- [x] Controls access to code that should run synchronously.## Install
For Deno:
```sh
$ deno add @117/mutex
```## Example
```ts
import { createMutex } from "@117/mutex";const mutex = createMutex();
const work = async () => {
await mutex.acquire();try {
console.log("mutex acquired, doing work");
} finally {
mutex.release();
}
};// they will not run concurrently
await Promise.all([work(), work()]);
```## Contributing
Feel free to contribute and PR to your 💖's content.