UNPKG

prex

Version:

Async coordination primitives and extensions on top of ES6 Promises

37 lines (35 loc) 1.34 kB
/*! ***************************************************************************** Copyright (c) Microsoft Corporation. Licensed under the Apache License, Version 2.0. See LICENSE file in the project root for details. ***************************************************************************** */ import { CancellationToken } from "./cancellation"; import { Cancelable } from "@esfx/cancelable"; /** * Asynchronously notifies one or more waiting Promises that an event has occurred. */ export declare class AutoResetEvent { private _signaled; private _waiters; /** * Initializes a new instance of the AutoResetEvent class. * * @param initialState A value indicating whether to set the initial state to signaled. */ constructor(initialState?: boolean); /** * Sets the state of the event to signaled, resolving one or more waiting Promises. * The event is then automatically reset. */ set(): void; /** * Sets the state of the event to nonsignaled, causing asynchronous operations to pause. */ reset(): void; /** * Asynchronously waits for the event to become signaled. * * @param token A CancellationToken used to cancel the request. */ wait(token?: CancellationToken | Cancelable): Promise<void>; }