How to use the @esfx/async-mutex.AsyncMutex function in @esfx/async-mutex

To help you get started, we’ve selected a few @esfx/async-mutex examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github esfx / esfx / packages / async-conditionvariable / src / __tests__ / conditionvariable.ts View on Github external
it("wait one", async () => {
        const m = new AsyncMutex();
        const cv = new AsyncConditionVariable();
        let ready = false;
        let processed = false;
        const steps: string[] = [];

        const worker = async () => {
            steps.push("worker1");

            // Wait until 'main' sends data
            {
                const lk = await m.lock();
                try {
                    steps.push("worker2");

                    // release the lock and wait to reacquire it.
                    await cv.wait(lk, () => ready);

@esfx/async-mutex

Provides 'AsyncMutex', an async coordination primitive.

Apache-2.0
Latest version published 2 years ago

Package Health Score

48 / 100
Full package analysis

Popular @esfx/async-mutex functions

Similar packages