deno-async
deno-async copied to clipboard
feature: add support disposing
please add support use using Symbol.dispose and Sympol.asyncDispose
import { AsyncValue } from "https://deno.land/x/[email protected]/testutil.ts";
import { Mutex } from "https://deno.land/x/[email protected]/mutex.ts";
const count = new AsyncValue(0);
async function doSomething() {
const v = await count.get();
await count.set(v + 1);
}
// Critical section
const mu = new Mutex();
// with using operator
{
using lock = await mutex.acquire();
await doSomething();
} // auto call lock[Symbol.dispose]();
// or with try finally
await mu.acquire();
try {
await doSomething();
} finally {
mu.release();
}
and publish package to jsr.io for using this package in node, bun, deno, ...
Package is published to JSR. https://jsr.io/@lambdalisue/async
Package with new API will be published to https://jsr.io/@core/asyncutil
Closed by #24