Class that represents the execution of a single task within a parallelized frame.

category | DocBlox
package | Parallel
author | Mike van Riel
license | MIT
link | http://docblox-project.org

### Methods

## Creates the worker and sets the task to execute optionally including the arguments that need to be passed to the task.

    __construct(callback $task, array $arguments)

### Parameters

#### $task

`callback`

The task to invoke upon execution.

#### $arguments

`mixed[]`

The arguments to provide to the task.

## Invokes the task with the given arguments and processes the output.

    execute() : \void.

### Returns

`\void.`

## Returns the list of arguments as provided int he constructor.

    getArguments() : mixed[]

see | \global\DocBlox_Parallel_Worker::__construct()

### Returns

`mixed[]`

## Returns the error message associated with the return code.

    getError() : string

### Returns

`string`

## Returns the result for this task run.

    getResult() : null | mixed

### Returns

`null` `mixed`

## Returns the available return code.

    getReturnCode() : int

This method may return -1 if no return code is available yet.

### Returns

`int`

## Returns the task as provided in the constructor.

    getTask() : callback

see | \global\DocBlox_Parallel_Worker::__construct()

### Returns

`callback`

## Sets the error message.

    setError(string $error) : void

### Parameters

#### $error

`string`

The error message.

## Sets the result for this task run.

    setResult(mixed $result) : void

### Parameters

#### $result

`mixed`

The value that is returned by the task; can be anything.

## Sets the return code for this worker.

    setReturnCode(int $return_code) : void

Recommended is to use the same codes as are used with exit codes.

In short: 0 means that the task succeeded and a any other positive value indicates an error condition.

### Parameters

#### $return_code

`int`

Recommended to be a positive number

### Exceptions

`\InvalidArgumentException` | if the code is not a number or negative

## Sets the task for this worker and validates whether it is callable.

    setTask(callback $task) : void

see | \global\DocBlox_Parallel_Worker::__construct()
see | \global\DocBlox_Parallel_Worker::execute()

### Parameters

#### $task

`callback`

The task to execute when the execute method is invoked.

### Exceptions

`\InvalidArgumentException` | if the given argument is not a callback.

### Properties

## A list of argument to pass to the task

    $arguments : mixed[]

## The error message, if an error occurred

    $error : string

## The result of the given task

    $result : mixed

## The return code to tell the parent process how it went

    $return_code : int

## the task to execute for this worker

    $task : callback