Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ConditionVariable

Condition variable.

The ConditionVariable class blocks critical sections until be notified.

author

Jeongho Nam - https://github.com/samchon

Hierarchy

  • ConditionVariable

Index

Type aliases

Constructors

Methods

Type aliases

Static Predicator

Predicator: () => boolean | Promise<boolean>

Type of predicator function who determines the completion.

Type declaration

    • (): boolean | Promise<boolean>
    • Returns boolean | Promise<boolean>

Constructors

constructor

Methods

notify_all

  • notify_all(): Promise<void>

notify_one

  • notify_one(): Promise<void>

wait

  • wait(): Promise<void>
  • wait(predicator: Predicator): Promise<void>

wait_for

  • wait_for(ms: number): Promise<boolean>
  • wait_for(ms: number, predicator: Predicator): Promise<boolean>
  • Wait for timeout or until notified.

    Parameters

    • ms: number

      The maximum miliseconds for waiting.

    Returns Promise<boolean>

    Whether awaken by notification or timeout.

  • Wait until timeout or predicator returns true.

    This method is equivalent to:

    const at: Date = new Date(Date.now() + ms);
    while (!await predicator())
    {
    if (!await this.wait_until(at))
    return await predicator();
    }
    return true;

    Parameters

    • ms: number

      The maximum miliseconds for waiting.

    • predicator: Predicator

      A predicator function determines the completion.

    Returns Promise<boolean>

    Returned value of the predicator.

wait_until

  • wait_until(at: Date): Promise<boolean>
  • wait_until(at: Date, predicator: Predicator): Promise<boolean>
  • Wait until notified or time expiration.

    Parameters

    • at: Date

      The maximum time point to wait.

    Returns Promise<boolean>

    Whether awaken by notification or time expiration.

  • Wait until time expiration or predicator returns true.

    This method is equivalent to:

    while (!await predicator())
    {
    if (!await this.wait_until(at))
    return await predicator();
    }
    return true;

    Parameters

    • at: Date

      The maximum time point to wait.

    • predicator: Predicator

      A predicator function determines the completion.

    Returns Promise<boolean>

    Returned value of the predicator.

Generated using TypeDoc