Skip to content

Latest commit

 

History

History
51 lines (34 loc) · 957 Bytes

README.md

File metadata and controls

51 lines (34 loc) · 957 Bytes

mutex

version status

A mutex implementation for Deno that supports async/await.

Contents

Features

  • Simple and lightweight.
  • Controls access to code that should run synchronously.

Install

For Deno:

$ deno add @117/mutex

Example

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.