Documentation - v19.12.0-dev
    Preparing search index...

    Class WorkerController<TInputMessage, TOutputMessage>

    Controller for calling multiple webworkers asynchronously

    Type Parameters

    • TInputMessage
    • TOutputMessage
    Index

    Constructors

    Properties

    ignoreWorkerMessage: boolean = false

    Whether to ignore message received from workers

    onerror: OnWorkerErrorCallback = EmptyCallback
    onmessage: OnWorkerMessageCallback<TOutputMessage> = EmptyCallback
    onmessageerror: OnWorkerMessageErrorCallback = EmptyCallback

    Accessors

    • get maxWorkers(): number

      Maximum number of workers the controller can allocate

      Returns number

    • set maxWorkers(value: number): void

      Parameters

      • value: number

      Returns void

    Methods

    • Returns whether all the worker are free

      Returns boolean

    • Frees all the workers

      Returns void

    • Frees the given worker

      Parameters

      • workerId: number

      Returns void

    • Returns whether the controller has free workers

      Returns boolean

    • Locks the given worker

      Parameters

      • workerId: number

      Returns void

    • Returns the next workerId available in the stack

      Returns number | null

    • Posts a message to the next available worker

      Parameters

      • message: TInputMessage

        Input message

      • transfer: Transferable[] = []

        Transferable objects

      Returns number

      The id of the worker that handled the message

    • Posts a message to a specific worker

      Parameters

      • workerId: number

        The id of the worker to use

      • message: TInputMessage

        Input message

      • transfer: Transferable[] = []

        Transferable objects

      Returns void

    • Reset controller workers

      Returns void

    • Stop jobs

      Returns void

    • Terminate a worker in the controller

      Parameters

      • workerId: number

      Returns void

    • Terminates all the workers in the controller

      Returns void