Documentation

ClosureWorker
in package
implements WorkerInterface

The Closure Worker Class

Table of Contents

Interfaces

WorkerInterface
The Interface for worker processes

Properties

$create  : Closure
$destroy  : Closure
$run  : Closure
$semaphore  : Semaphore
$storage  : ArrayObject

Methods

__construct()  : mixed
The constructor
onProcessCreate()  : mixed
After the worker has been forked into another process
onProcessDestroy()  : mixed
Before the worker process is getting destroyed
run()  : Serializable
run the work

Properties

$create

protected Closure $create

Closure that runs the task

$destroy

protected Closure $destroy

Closure that will be used before a worker is getting destroyed

$run

protected Closure $run

Closure that will be used when a worker has been forked

$storage

protected ArrayObject $storage

persistent storage container for the working process

Methods

__construct()

The constructor

public __construct(Closure $run[, Closure $create = NULL ][, Closure $destroy = NULL ]) : mixed
Parameters
$run : Closure

Closure that runs the task

$create : Closure = NULL

Closure that can be used when a worker has been forked

$destroy : Closure = NULL

Closure that can be used before a worker is getting destroyed

onProcessCreate()

After the worker has been forked into another process

public onProcessCreate(Semaphore $semaphore) : mixed
Parameters
$semaphore : Semaphore

the semaphore to run synchronized tasks

Tags
throws
Exception

in case of a processing Error an Exception will be thrown

onProcessDestroy()

Before the worker process is getting destroyed

public onProcessDestroy() : mixed
Tags
throws
Exception

in case of a processing Error an Exception will be thrown

run()

run the work

public run(Serializable $input) : Serializable
Parameters
$input : Serializable

the data, that the worker should process

Tags
throws
Exception

in case of a processing Error an Exception will be thrown

Return values
Serializable

Returns the result


        
On this page

Search results