Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RemoteLatch

Remote Latch.

The RemoteLatch class blocks critical sections until the downward counter to be zero. Howver, unlike RemoteBarrier who can reusable that downward counter be reset whenever reach to the zero, downward of the RemoteLatch is not reusable but diposable.

author

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

Hierarchy

  • RemoteLatch

Index

Methods

arrive_and_wait

  • arrive_and_wait(): Promise<void>
  • Decrements the counter and waits until the counter to be zero.

    Decrements the counter by n and blocks the section until internal counter to be zero.

    If the parametric value n is equal to or greater than internal counter, so that the internal counter be equal to or less than zero, everyone who are waiting for the RemoteLatch would continue their execution including this one.

    Returns Promise<void>

count_down

  • count_down(n?: number): Promise<void>
  • Derecements the counter.

    Decrements the counter by n without blocking.

    If the parametric value n is equal to or greater than internal counter, so that the internal counter be equal to or less than zero, everyone who are waiting for the RemoteLatch would continue their execution.

    Parameters

    • Default value n: number = 1

      Value of the decrement. Default is 1.

    Returns Promise<void>

try_wait

  • try_wait(): Promise<boolean>
  • Test whether the counter has been reached to the zero.

    The try_wait function tests whether the internal counter has been reached to the zero.

    Returns Promise<boolean>

    Whether reached to zero or not.

wait

  • wait(): Promise<void>
  • Waits until the counter to be zero.

    Blocks the function calling until internal counter to be reached to the zero.

    If the RemoteLatch already has been reached to the zero, it would be returned immediately.

    Returns Promise<void>

wait_for

  • wait_for(ms: number): Promise<boolean>
  • Tries to wait until the counter to be zero in timeout.

    Attempts to block the function calling until internal counter to be reached to the zero in timeout. If succeeded to waiting the counter to be reached to the zero, it returns true. Otherwise, the RemoteLatch fails to reach to the zero in the given time, the function gives up the waiting and returns false.

    If the RemoteLatch already has been reached to the zero, it would return true directly.

    Parameters

    • ms: number

      The maximum miliseconds for waiting.

    Returns Promise<boolean>

    Whether succeeded to waiting in the given time.

wait_until

  • wait_until(at: Date): Promise<boolean>
  • Tries to wait until the counter to be zero in time expiration.

    Attempts to block the function calling until internal counter to be reached to the zero in time expiration. If succeeded to waiting the counter to be reached to the zero, it returns true. Otherwise, the RemoteLatch fails to reach to the zero in the given time, the function gives up the waiting and returns false.

    If the RemoteLatch already has been reached to the zero, it would return true directly.

    Parameters

    • at: Date

      The maximum time point to wait.

    Returns Promise<boolean>

    Whether succeeded to waiting in the given time.

Generated using TypeDoc