Skip to content
/ mutex Public

A mutex implementation for Deno that supports async/await.

License

Notifications You must be signed in to change notification settings

117/mutex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A mutex implementation for Deno that supports async/await.

Topics

Resources

License

Stars

Watchers

Forks