\duncan3dc\ForkerSingleThreadAdapter

Handle executing code in a single thread.

Summary

Methods
Properties
Constants
call()
wait()
getExceptions()
cleanup()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$pid
$exceptions
$status
N/A

Properties

$pid

$pid : integer

Type

integer — The latest process ID issued.

$exceptions

$exceptions : array<mixed,\Throwable>

Type

array<mixed,\Throwable> — Caught exceptions from the threads.

$status

$status : array<mixed,integer>

Type

array<mixed,integer> — The exit code for each thread.

Methods

call()

call(callable  $func, mixed  $args) : integer

Run some code in a thread.

Parameters

callable $func

The function to execute

mixed $args

The arguments to pass to the function

Returns

integer —

The pid of the thread created to execute this code

wait()

wait(integer  $pid) : integer

Wait for the a thread started via call() to end.

Parameters

integer $pid

The pid to wait for

Returns

integer —

The exit code of the thread

getExceptions()

getExceptions() : array<mixed,\Throwable>

Get any exceptions thrown by the threads.

Returns

array<mixed,\Throwable>

cleanup()

cleanup() : void

Method to be called when the adapter is finished with.

A destructor can't be used as instances in forked threads will be destroyed twice.