Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nitrogen/mutagen
Erlang mutex server (originally built for Nitrogen, but usable anywhere)
https://github.com/nitrogen/mutagen
erlang mutex
Last synced: 4 days ago
JSON representation
Erlang mutex server (originally built for Nitrogen, but usable anywhere)
- Host: GitHub
- URL: https://github.com/nitrogen/mutagen
- Owner: nitrogen
- License: apache-2.0
- Created: 2023-09-13T20:33:24.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2023-09-13T20:50:46.000Z (about 1 year ago)
- Last Synced: 2024-04-25T15:20:44.375Z (7 months ago)
- Topics: erlang, mutex
- Language: Erlang
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Mutagen
Mutagen is a simple mutex server for the [Nitrogen Web
Framework](http://nitrogenproject.com). It was previously part of [Nitro
Cache](https://github.com/nitrogen/nitro_cache) but has been pulled out and
generalized in case a more generalized mutex system is needed for Erlang and/or
Nitrogen users.## Add to your rebar.config
```erlang
{deps, [
mutagen
]}.
```## Make sure you start it
Either:
* Add it to the `applications` list in your `.app.src` file, or
* Start it manually with `application:ensure_all_started(mutagen).`## Usage
Mutagen has a few very simple functions, once the server is running.
* `lock(Key) -> fail | success`: Attempt to lock the mutex `Key`. If the mutex
is successfully locked, the call will return `success`. If the mutex is
already locked, the mutex will return `fail`.* `lock(Key, Timeout) -> fail | success`: Attempt the lock mutex `Key`,
however, if the mutex is currently already locked, the call will stall and
wait up to `Timeout` milliseconds before giving up and returning `fail`.* `wait(Key) -> free`: Only return when the mutex identified by `Key` is free.
This does not then lock the mutex, it merely returns when it's available.* `wait(Key, Timeout) -> free | not_free`: Only returns `free` when the mutex
identified by `Key` is free, or if the mutex is not free after `Timeout`
milliseconds, return `not_free`.* `status() -> StatusInfo`: Returns a proplist of information related to the
number of mutexes that are currently locked, the number of processes queued
to lock an already locked mutex, and the number of processes waiting for the
mutex to be free.## About
Apache 2.0 License
Copyright 2023 Jesse Gumm