import { Semaphore } from "https://deno.land/x/async@v2.0.2/mod.ts";
A semaphore that allows a limited number of concurrent executions of an operation.
import { Semaphore } from "./semaphore.ts";
const sem = new Semaphore(5);
const worker = () => {
return sem.lock(async () => {
// do something
});
};
await Promise.all([...Array(10)].map(() => worker()));