async-mutex
Advanced tools
Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "async-mutex", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "A mutex for guarding async workflows", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -0,1 +1,4 @@ | ||
[![Build Status](https://travis-ci.org/DirtyHairy/async-mutex.svg?branch=master)](https://travis-ci.org/DirtyHairy/async-mutex) | ||
[![npm version](https://badge.fury.io/js/async-mutex.svg)](https://badge.fury.io/js/async-mutex) | ||
# What is it? | ||
@@ -71,13 +74,15 @@ | ||
mutex.acquire(function(release) { | ||
// ... | ||
}); | ||
mutex | ||
.acquire() | ||
.then(function(release) { | ||
// ... | ||
}); | ||
`acquire` schedules the supplied callback to be executed once the mutex is unlocked. | ||
The mutex is locked during execution. Once the callback has finished its work, it | ||
calls `release()` in order to release the mutex. | ||
`acquire` returns an (ES6) promise that will resolve as soon as the mutex is | ||
available and ready to be accessed. The promise resolves with a function `release` that | ||
must be called once the mutex should be released again. | ||
**IMPORTANT:** `acquire` will not take care of any exceptions throws during execution | ||
of the callback --- it is your own responsibility to make sure that the mutex is | ||
released in case of an exception. | ||
**IMPORTANT:** Failure to call `release` will hold the mutex locked and will | ||
lilely deadlock the application. Make sure to call `release` under all circumstances | ||
and handle exceptions accordingly. | ||
@@ -84,0 +89,0 @@ ### Synchronized code execution |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
110
12883
231