Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);