Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/rimbu/channel/mod.ts>Mutex

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
namespace Mutex
Re-export
import { Mutex } from "https://deno.land/x/rimbu@1.2.0/channel/mod.ts";

Interfaces

Defines the static Mutex API.

interface Mutex
Re-export
import { type Mutex } from "https://deno.land/x/rimbu@1.2.0/channel/mod.ts";

A Mutex is used to restrict access to a shared resource in a concurrent environment. The Mutex can be used to acquire a lock for the resource, preventing others using the Mutext from accessing the resource. When finished using the resource, the lock can be released, allowing other waiting processes to acquire a lock.

Methods

canAcquire(): boolean

Returns true if the resource can be acquired immediately, false otherwise.

acquire(): Promise<void>

Acquire a lock. Blocks if the resource is already locked. Resolves when the resource is available.

release(): void

Release a lock after it is acquired. Allows other functions to obtain a lock.

variable Mutex
Re-export
import { Mutex } from "https://deno.land/x/rimbu@1.2.0/channel/mod.ts";