UNPKG

1.98 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 * An event that is set when all participants have signaled.
11 */
12export declare class CountdownEvent {
13 private _initialCount;
14 private _remainingCount;
15 private _event;
16 /**
17 * Initializes a new instance of the CountdownEvent class.
18 *
19 * @param initialCount The initial participant count.
20 */
21 constructor(initialCount: number);
22 /**
23 * Gets the number of signals initially required to set the event.
24 */
25 get initialCount(): number;
26 /**
27 * Gets the number of remaining signals required to set the event.
28 */
29 get remainingCount(): number;
30 /**
31 * Increments the event's current count by one or more.
32 *
33 * @param count An optional count specifying the additional number of signals for which the event will wait.
34 */
35 add(count?: number): void;
36 /**
37 * Resets the remaining and initial count to the specified value, or the initial count.
38 *
39 * @param count An optional count specifying the number of required signals.
40 */
41 reset(count?: number): void;
42 /**
43 * Registers one or more signals with the CountdownEvent, decrementing the remaining count.
44 *
45 * @param count An optional count specifying the number of signals to register.
46 */
47 signal(count?: number): boolean;
48 /**
49 * Asynchronously waits for the event to become signaled.
50 *
51 * @param token An optional CancellationToken used to cancel the request.
52 */
53 wait(token?: CancellationToken | Cancelable): Promise<void>;
54}