UNPKG

1.34 kBTypeScriptView Raw
1/*! *****************************************************************************
2Copyright (c) Microsoft Corporation.
3Licensed under the Apache License, Version 2.0.
4
5See LICENSE file in the project root for details.
6***************************************************************************** */
7import { CancellationToken } from "./cancellation";
8import { Cancelable } from "@esfx/cancelable";
9/**
10 * Asynchronously notifies one or more waiting Promises that an event has occurred.
11 */
12export declare class AutoResetEvent {
13 private _signaled;
14 private _waiters;
15 /**
16 * Initializes a new instance of the AutoResetEvent class.
17 *
18 * @param initialState A value indicating whether to set the initial state to signaled.
19 */
20 constructor(initialState?: boolean);
21 /**
22 * Sets the state of the event to signaled, resolving one or more waiting Promises.
23 * The event is then automatically reset.
24 */
25 set(): void;
26 /**
27 * Sets the state of the event to nonsignaled, causing asynchronous operations to pause.
28 */
29 reset(): void;
30 /**
31 * Asynchronously waits for the event to become signaled.
32 *
33 * @param token A CancellationToken used to cancel the request.
34 */
35 wait(token?: CancellationToken | Cancelable): Promise<void>;
36}