import { Lock } from "https://deno.land/x/dpp_vim@v0.2.0/deps.ts";
A mutual exclusion lock that provides safe concurrent access to a shared value.
import { AsyncValue } from "https://deno.land/x/async@v0.2.0/testutil.ts";
import { Lock } from "https://deno.land/x/async@v0.2.0/lock.ts";
// Critical section
const count = new Lock(new AsyncValue(0));
await count.lock(async (count) => {
const v = await count.get();
count.set(v + 1);
});