Class: ParallelExecutor

olympe.async. ParallelExecutor

A ParallelExecutor launches all the asynchronous tasks at the same time. It will be successful if, and only if all the tasks completed successfully.


new ParallelExecutor( [context] [, autoDestroy])

Creates a ParallelExecutor.

Parameters:
Name Type Argument Description
context olympe.df.ExecutionContext <optional>

The ExecutionContext to use for running the callbacks. Default is the current context.

autoDestroy boolean <optional>

true to automatically destroy the ExecutionContext on completion. Default is true if no context is provided, false otherwise.

Extends

Members


<protected, non-null> callbacks :Array.<function(boolean, ?string, Map.<string, *>)>

Type:
  • Array.<function(boolean, ?string, Map.<string, *>)>
Inherited From:
Overrides:

<protected> ended :boolean

Type:
  • boolean
Inherited From:
Overrides:

<protected, non-null> env :Map.<string, *>

Type:
  • Map.<string, *>
Inherited From:
Overrides:

<protected, nullable> errorMsg :string

Type:
  • string
Inherited From:
Overrides:

<protected> logger :olympe.logging.Channel

Type:
  • olympe.logging.Channel
Inherited From:
Overrides:

<protected> started :boolean

Type:
  • boolean
Inherited From:
Overrides:

<protected, non-null> tasks :Array.<olympe.async.Task>

Type:
Inherited From:
Overrides:

Methods


<static> create()

Creates a ParallelExecutor with an auto-destructing context.

Returns:
Type
olympe.async.ParallelExecutor

add(task)

Adds a task to this Executor. If this Executor is already started, the task will be started immediately. On the other hand, if this Executor has already completed, the new task is ignored.

Parameters:
Name Type Description
task olympe.async.Task

The task to add.

Inherited From:
Overrides:
Returns:

this Executor.

Type
olympe.async.Executor

<protected> clear()

Clears the executor: remove all tasks and callbacks.

Inherited From:
Overrides:

<protected> complete(success)

Notifies the end of the execution and triggers the callbacks.

Parameters:
Name Type Description
success boolean

Whether the execution was successful or not.

Inherited From:
Overrides:

getContext()

Gets the ExecutionContext associated with this Executor.

Inherited From:
Overrides:
Returns:
Type
olympe.df.ExecutionContext

getLogger()

Gets the logger attached to this Executor.

Inherited From:
Overrides:
Returns:

The attached logger.

Type
olympe.logging.Channel

hasEnded()

Checks whether this Executor has completed its execution.

Inherited From:
Overrides:
Returns:

true when the Executor has ended.

Type
boolean

isRunning()

Checks whether this Executor is currently running one or more tasks.

Inherited From:
Overrides:
Returns:

true when the Executor is running.

Type
boolean

onEnd(callback)

Registers a callback to be called when the Executor has completed. The callback is passed a boolean, true if all the tasks completed successfully, false otherwise.

Parameters:
Name Type Description
callback function

The function to register.

Inherited From:
Overrides:
Returns:

this Executor.

Type
olympe.async.Executor

start()

Starts the executor. Does nothing if it had already been started.

Inherited From:
Overrides:

withLogger(logger)

Attach a logger to this executor.

Parameters:
Name Type Description
logger olympe.logging.Channel

The logger to attach.

Inherited From:
Overrides:
Returns:

this Executor.

Type
olympe.async.Executor

withTimeout(t)

Sets a timeout for the executor. If all the tasks in this Executor are not completed within the specified time the Executor will complete as failed. All pending tasks will be cancelled.

Parameters:
Name Type Description
t number

timeout in milliseconds.

Inherited From:
Overrides:
Returns:

this Executor.

Type
olympe.async.Executor