prex-es5
Version:
Async coordination primitives and extensions on top of ES6 Promises
54 lines (52 loc) • 1.88 kB
TypeScript
/*! *****************************************************************************
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";
/**
* An event that is set when all participants have signaled.
*/
export declare class CountdownEvent {
private _initialCount;
private _remainingCount;
private _event;
/**
* Initializes a new instance of the CountdownEvent class.
*
* @param initialCount The initial participant count.
*/
constructor(initialCount: number);
/**
* Gets the number of signals initially required to set the event.
*/
readonly initialCount: number;
/**
* Gets the number of remaining signals required to set the event.
*/
readonly remainingCount: number;
/**
* Increments the event's current count by one or more.
*
* @param count An optional count specifying the additional number of signals for which the event will wait.
*/
add(count?: number): void;
/**
* Resets the remaining and initial count to the specified value, or the initial count.
*
* @param count An optional count specifying the number of required signals.
*/
reset(count?: number): void;
/**
* Registers one or more signals with the CountdownEvent, decrementing the remaining count.
*
* @param count An optional count specifying the number of signals to register.
*/
signal(count?: number): boolean;
/**
* Asynchronously waits for the event to become signaled.
*
* @param token An optional CancellationToken used to cancel the request.
*/
wait(token?: CancellationToken): Promise<void>;
}