@esfx/async-autoresetevent
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

The @esfx/async-autoresetevent package provides the AsyncAutoResetEvent class, an async coordination primitive.

Overview

Installation

npm i @esfx/async-autoresetevent

Usage

import { AsyncAutoResetEvent } from "@esfx/async-autoresetevent";

const event = new AsyncAutoResetEvent();

async function doSomeActivity() {
    while (true) {
        // do some work asynchronously...

        // indicate 'waitForActivity' can resume. Event is immediately reset to
        // the unsignaled state.
        event.set();
    }
}

async function waitForActivity() {
    while (true) {
        // wait for 'doSomeActivity' to set the event...
        await event.wait();

        // do something asynchronous...
    }
}

doSomeActivity();
waitForActivity();

API

You can read more about the API here.

Readme

Keywords

none

Package Sidebar

Install

npm i @esfx/async-autoresetevent

Weekly Downloads

76

Version

1.0.0

License

Apache-2.0

Unpacked Size

36 kB

Total Files

9

Last publish

Collaborators

  • rbuckton