Class WaitGroupSealed

A WaitGroup waits for a collection of async process to finish.

Remarks

The main process calls Add to set the number of async process to wait for. Then each of the async process runs and calls done when finished. At the same time, wait can be used to block until all async process have finished.

Hierarchy

  • WaitGroup

Constructors

Properties

Accessors

Methods

Constructors

Properties

c_: undefined | Completer<undefined>

Signals are used to notify waiting for a function to return

counter_: number = 0

Record how many async awaits are in progress

Accessors

Methods

  • Add adds delta, which may be negative, to the WaitGroup counter. If the counter becomes zero, all goroutines blocked on Wait are released. If the counter goes negative, Add throws Exception.

    Throws

    Exception

    Parameters

    • delta: number

      WaitGroup.counter += delta

    Returns void

  • Execute function f after counter++, and execute counter-- after function f is done

    Returns

    If a promise is returned, the function f is completed after the promise is executed, otherwise the function f is already completed

    Parameters

    • f: (() => any)

      function to execute

        • (): any
        • Returns any

    • Optional oncompleted: VoidCallback

      function to execute when f is done

    Returns void

  • Done decrements the WaitGroup counter by one.

    Throws

    Exception

    Returns void

  • If WaitGroup counter is zero return undefined, else return a Promise for waiting until the counter is zero.

    Returns undefined | Promise<undefined>

Generated using TypeDoc