@jetjs/threadpool

interface ExecutorPool

Methods

MethodReturnDescription
addTaskConfiguration(config)
void
isTerminated()
boolean
shutdown()
Promise
submit(taskDef)
Promise

Method Details

  • addTaskConfiguration(config) Method

    Adds a new task configurations to the executor. Multiple configurations can be passed as comma separated argument list. Task configurations are optional, but they are important to define the source to load. So the Worker is able to load and execute a given Task.

    For each Task there can be only one Configuration.

    If no configuration is provided for a task, we assume that the script is bundled within the Worker-Script or the Task-Definition contains a separated TaskSource to load.

    Configuration can be provided separated from task submission, because these type of information is often static and not dynamic. e.g. Some bundled Scripts that contain multiple tasks

    see TaskConfiguration

    Signature:
    addTaskConfiguration(...config: TaskConfiguration[]): void;
    Returns:
    void
    ParameterTypeDescription
    config
    TaskConfiguration[]
  • isTerminated() Method

    Signature:
    isTerminated(): boolean;
    Returns:
    boolean

    true if #shutdown was called previously.

  • shutdown() Method

    Terminates all allocated Workers. Afterwards the ExecutorPoll will not be useable anymore.

    Signature:
    shutdown(): Promise<void>;
    Returns:
    Promise
  • submit(taskDef) Method

    Signature:
    submit<P, R>(taskDef: TaskDefinition<P>): Promise<R>;
    Returns:
    Promise
    ParameterTypeDescription
    taskDef
    TaskDefinition

    Submits a Task to be executed by a worker.

    type P: Task Parameter Type type R: Task Result Type