UNPKG

rc-js-util

Version:

A collection of TS and C++ utilities to help writing performant and correct applications, achieved through strict typing and (removable) invariant checking.

24 lines 791 B
/** * @public * Provides a way to poll without busy waiting. Useful for synchronization with workers, particularly with shared memory. */ export interface INonblockingPoll { cancel(): void; getPromise(): Promise<EResolutionState>; } /** * @public */ export declare enum EResolutionState { Resolved = 0, TimedOut = 1, Cancelled = 2 } /** * @public * @param predicate - Once true, the poll finishes. Exceptions are not supported. * @param pollInterval - In milliseconds, defaults to smallest (probably 4 ms). * @param maxTicks - The number of times to run the poll before giving up. */ export declare function promisePoll(predicate: () => boolean, pollInterval?: number | undefined, maxTicks?: number): INonblockingPoll; //# sourceMappingURL=promise-poll.d.ts.map