DocBlox_Parallel_Worker

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

category

DocBlox

package

Parallel

author

Mike van Riel mike.vanriel@naenius.com

license

http://www.opensource.org/licenses/mit-license.php 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<mixed,mixed> $arguments = array()) 

Arguments

$task

callback

The task to invoke upon execution.

$arguments

array<mixed,mixed>

The arguments to provide to the task.

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

execute() : \void.

Response

\void.

Returns the list of arguments as provided in the constructor.

getArguments() : array<mixed,mixed>
see \DocBlox_Parallel_Worker::__construct()

Response

array<mixed,mixed>

Returns the error message associated with the return code.

getError() : string

Response

string

Returns the result for this task run.

getResult() : null|mixed

Response

null|mixed

Returns the available return code.

getReturnCode() : integer

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

Response

integer

Returns the task as provided in the constructor.

getTask() : callback

Sets the error message.

setError(string $error) : void

Arguments

$error

string

The error message.

Sets the result for this task run.

setResult(mixed $result) : void

Arguments

$result

mixed

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

Sets the return code for this worker.

setReturnCode(integer $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.

throw

if the code is not a number or negative

Arguments

$return_code

integer

Recommended to be a positive number

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

setTask(callback $task) : void
throws

if the given argument is not a callback.

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

Arguments

$task

callback

The task to execute when the execute method

is invoked.

Properties

the task to execute for this worker

task : callback
var

the task to execute for this worker

Type(s)

callback

A list of argument to pass to the task

arguments : array<mixed,mixed>
var

A list of argument to pass to the task

Type(s)

array<mixed,mixed>

The return code to tell the parent process how it went

return_code : integer
var

The return code to tell the parent process how it went

Type(s)

integer

The result of the given task

result : mixed
var

The result of the given task

Type(s)

mixed

The error message, if an error occurred

error : string
var

The error message, if an error occurred

Type(s)

string