Giter VIP home page Giter VIP logo

mutagen's Introduction

Mutagen

Mutagen is a simple mutex server for the Nitrogen Web Framework. It was previously part of 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

{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

mutagen's People

Contributors

choptastic avatar

Watchers

James Cloos avatar

Forkers

7006

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.