async-mutex
- Version 0.5.0
- Published
- 63 kB
- 1 dependency
- MIT license
Install
npm i async-mutex
yarn add async-mutex
pnpm add async-mutex
Overview
A mutex for guarding async workflows
Index
Variables
Functions
Classes
Interfaces
Namespaces
Variables
variable E_ALREADY_LOCKED
const E_ALREADY_LOCKED: Error;
variable E_CANCELED
const E_CANCELED: Error;
variable E_TIMEOUT
const E_TIMEOUT: Error;
Functions
function tryAcquire
tryAcquire: { (mutex: MutexInterface, alreadyAcquiredError?: Error): MutexInterface; ( semaphore: SemaphoreInterface, alreadyAcquiredError?: Error ): SemaphoreInterface;};
function withTimeout
withTimeout: { (mutex: MutexInterface, timeout: number, timeoutError?: Error): MutexInterface; ( semaphore: SemaphoreInterface, timeout: number, timeoutError?: Error ): SemaphoreInterface;};
Classes
class Mutex
class Mutex implements MutexInterface {}
constructor
constructor(cancelError?: Error);
method acquire
acquire: (priority?: number) => Promise<MutexInterface.Releaser>;
method cancel
cancel: () => void;
method isLocked
isLocked: () => boolean;
method release
release: () => void;
method runExclusive
runExclusive: <T>( callback: MutexInterface.Worker<T>, priority?: number) => Promise<T>;
method waitForUnlock
waitForUnlock: (priority?: number) => Promise<void>;
class Semaphore
class Semaphore implements SemaphoreInterface {}
constructor
constructor(_value: number, _cancelError?: Error);
method acquire
acquire: ( weight?: number, priority?: number) => Promise<[number, SemaphoreInterface.Releaser]>;
method cancel
cancel: () => void;
method getValue
getValue: () => number;
method isLocked
isLocked: () => boolean;
method release
release: (weight?: number) => void;
method runExclusive
runExclusive: <T>( callback: SemaphoreInterface.Worker<T>, weight?: number, priority?: number) => Promise<T>;
method setValue
setValue: (value: number) => void;
method waitForUnlock
waitForUnlock: (weight?: number, priority?: number) => Promise<void>;
Interfaces
interface MutexInterface
interface MutexInterface {}
method acquire
acquire: (priority?: number) => Promise<MutexInterface.Releaser>;
method cancel
cancel: () => void;
method isLocked
isLocked: () => boolean;
method release
release: () => void;
method runExclusive
runExclusive: <T>( callback: MutexInterface.Worker<T>, priority?: number) => Promise<T>;
method waitForUnlock
waitForUnlock: (priority?: number) => Promise<void>;
interface SemaphoreInterface
interface SemaphoreInterface {}
method acquire
acquire: ( weight?: number, priority?: number) => Promise<[number, SemaphoreInterface.Releaser]>;
method cancel
cancel: () => void;
method getValue
getValue: () => number;
method isLocked
isLocked: () => boolean;
method release
release: (weight?: number) => void;
method runExclusive
runExclusive: <T>( callback: SemaphoreInterface.Worker<T>, weight?: number, priority?: number) => Promise<T>;
method setValue
setValue: (value: number) => void;
method waitForUnlock
waitForUnlock: (weight?: number, priority?: number) => Promise<void>;
Namespaces
namespace MutexInterface
namespace MutexInterface {}
interface Releaser
interface Releaser {}
call signature
(): void;
interface Worker
interface Worker<T> {}
call signature
(): Promise<T> | T;
namespace SemaphoreInterface
namespace SemaphoreInterface {}
interface Releaser
interface Releaser {}
call signature
(): void;
interface Worker
interface Worker<T> {}
call signature
(value: number): Promise<T> | T;
Package Files (8)
Dependencies (1)
Dev Dependencies (16)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/async-mutex
.
- Markdown[](https://www.jsdocs.io/package/async-mutex)
- HTML<a href="https://www.jsdocs.io/package/async-mutex"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 974 ms. - Missing or incorrect documentation? Open an issue for this package.