deno-async icon indicating copy to clipboard operation
deno-async copied to clipboard

feature: add support disposing

Open PandaWorker opened this issue 1 year ago • 1 comments

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, ...

PandaWorker avatar Mar 27 '24 09:03 PandaWorker

Package is published to JSR. https://jsr.io/@lambdalisue/async

lambdalisue avatar Apr 06 '24 05:04 lambdalisue

Package with new API will be published to https://jsr.io/@core/asyncutil

Closed by #24

lambdalisue avatar Aug 04 '24 09:08 lambdalisue