@metreeca/core - v0.9.11
    Preparing search index...

    Interface Mutex

    Mutual exclusion primitive for coordinating asynchronous operations.

    Ensures that only one task executes at a time, even when multiple tasks are queued concurrently. Tasks are executed in FIFO order.

    interface Mutex {
        execute<T>(task: () => T | Promise<T>): Promise<T>;
    }
    Index

    Methods

    Methods

    • Executes a task with exclusive access.

      Waits for any previously queued tasks to complete before executing. The mutex is properly released even if the task throws an error.

      Type Parameters

      • T

        The type of value returned by the task

      Parameters

      • task: () => T | Promise<T>

        The function to execute with exclusive access

      Returns Promise<T>

      A promise that resolves to the task's return value