Documents for @litert/utils-async
    Preparing search index...

    Interface IFiberContext<T>

    The context of the fiber execution, used to exchanged data between the fiber and the controller. It also provides the abort signal to the fiber execution, so that the fiber can be aborted by the controller. Besides, it provides a sleep method to pause the fiber execution and wait for the controller to resume it.

    interface IFiberContext<T = DTypes.IDict> {
        data: T;
        signal: AbortSignal;
        sleep(): Promise<void>;
    }

    Type Parameters

    • T = DTypes.IDict
    Index

    Properties

    Methods

    Properties

    data: T

    The data of the fiber, used to store and swap data between fiber and the controller.

    signal: AbortSignal

    The abort signal of the fiber, used to abort the execution of the fiber.

    This signal object could be passed to all other asynchronous functions that accepting an AbortSignal in the parameters.

    Only work if the fiber listens to the signal.

    Methods

    • The fiber execution could call this method and wait for the controller to resume (or abort) it. This is useful when the fiber execution has nothing to do for a while, something like fiber-pooling management.

      The fiber execution should always pause itself by waiting for the promise. And if the promise is rejected, the fiber must quit its execution.

      Returns Promise<void>

      If the fiber is not running, it will throw an error.