A service that handles multithreading.

Implements

Constructors

Methods

  • Runs the given function on a separate thread. This will not persist the state in the data source.

    IMPORTANT: This uses "eval" in the thread worker, so make sure that the data passed is not malicious.

    Type Parameters

    • InputType
    • ResultType

    Parameters

    • func: ThreadJobFunction<InputType, ResultType>

      The function that should be run in a separate thread.

    • input: InputType

      The input value of the function.

    • Optionaltimeout: number

      A custom timeout for the task. Defaults to 5 minutes or an hour, depending on the priority.

    • priority: boolean = true

      Whether or not the function should make use of priority workers or not. Defaults to true.

    Returns Promise<ResultType>

    The result value of the function passed.

    When either the function itself throws an error or something didn't work during parsing/evaluation.