Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Strand

Provides serial execution for asynchronous code. Here are the semantics:

Strand holds an internal execution queue of completion callbacks. Each call to execute will push to the queue. When a callback in the queue finishes with either an exception or a regular return, the next callback in the queue will be dispatched. Callbacks are not executed until all prior callbacks have run to completion.

Hierarchy

  • Strand

Index

Properties

Methods

Properties

Private _tailPromise

_tailPromise: Thenable<void> = Promise.resolve()

Methods

Private _enqueue

  • _enqueue(fn: function): void
  • Parameters

    • fn: function
        • (): Promise<void>
        • Returns Promise<void>

    Returns void

execute

  • execute<T>(func: function): Thenable<T>
  • execute<T>(func: function): Thenable<T>
  • execute<T>(func: function): Thenable<T>
  • Enqueue a function for execution.

    Callbacks passed to execute() are always executed in order, and never started until the prior callbacks have executed.

    Type parameters

    • T

    Parameters

    • func: function

      The next completion callback

        • (): Thenable<T>
        • Returns Thenable<T>

    Returns Thenable<T>

    a Thenable that will resolve with the return value/exception of the enqueued function.

  • Type parameters

    • T

    Parameters

    • func: function
        • (): Promise<T>
        • Returns Promise<T>

    Returns Thenable<T>

  • Type parameters

    • T

    Parameters

    • func: function
        • (): T
        • Returns T

    Returns Thenable<T>

Generated using TypeDoc