Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | 1x 1x 1x 1x 1x 260x | import { WaitableConsumer, guard as guardWaitableConsumer } from "@jonloucks/concurrency-ts/api/WaitableConsumer";
import { WaitableNotify, guard as guardWaitableNotify } from "@jonloucks/concurrency-ts/api/WaitableNotify";
import { WaitableSupplier, guard as guardWaitableSupplier } from "@jonloucks/concurrency-ts/api/WaitableSupplier";
import { OptionalType, RequiredType, guardFunctions } from "@jonloucks/concurrency-ts/api/Types";
import { Open } from "@jonloucks/contracts-ts/api/Open";
import { Contracts } from "@jonloucks/contracts-ts";
/**
* Configuration for creating a Waitable
*/
export interface Config<T> {
/**
* Optional contracts for validation or other purposes
*/
contracts?: Contracts;
/**
* Optional initial value of the Waitable
*/
initialValue?: OptionalType<T>;
}
/**
* Export Waitable Config type
*/
export { Config as WaitableConfig } ;
/**
* Provides mutable reference that allows other threads to wait until
* the value satisfies a given condition.
*
* @param <T> the type of references
*/
export interface Waitable<T> extends Open, WaitableSupplier<T>, WaitableConsumer<T>, WaitableNotify<T> {
}
/**
* Determine if the given instance is a Waitable
*
* @param instance the instance to check
* @return true if the instance is a Waitable
*/
export function guard<T>(instance: unknown): instance is RequiredType<Waitable<T>> {
return guardFunctions(instance, 'open')
&& guardWaitableConsumer<T>(instance)
&& guardWaitableNotify<T>(instance)
&& guardWaitableSupplier<T>(instance);
} |