ThreadContext
extends AbstractContext
in package
Tags
Table of Contents
Constants
- DEFAULT_START_TIMEOUT = 5
- EXIT_CHECK_FREQUENCY = 0.25
Properties
- $autoloadPath : string|null
- $exited : bool
- $hub : ParallelHub
- $hubs : WeakMap|null
- $id : int
- $nextId : int
- $oid : int
- $runtime : Runtime
Methods
- __destruct() : mixed
- Kills the thread if it is still running.
- __serialize() : never
- __unserialize() : never
- close() : void
- Closes the resource, marking it as unusable.
- isClosed() : bool
- Returns whether this resource has been closed.
- isSupported() : bool
- Checks if threading is enabled.
- join() : TResult
- onClose() : void
- Registers a callback that is invoked when this resource is closed.
- receive() : TReceive
- send() : void
- start() : self
- __clone() : mixed
- receiveExitResult() : ExitResult
- __construct() : mixed
Constants
DEFAULT_START_TIMEOUT
private
mixed
DEFAULT_START_TIMEOUT
= 5
EXIT_CHECK_FREQUENCY
private
mixed
EXIT_CHECK_FREQUENCY
= 0.25
Properties
$autoloadPath
private
static string|null
$autoloadPath
= null
$exited
private
bool
$exited
= false
$hub read-only
private
ParallelHub
$hub
$hubs
private
static WeakMap|null
$hubs
= null
$id read-only
private
int
$id
$nextId
private
static int
$nextId
= 1
Next thread ID.
$oid read-only
private
int
$oid
$runtime read-only
private
Runtime
$runtime
Methods
__destruct()
Kills the thread if it is still running.
public
__destruct() : mixed
__serialize()
public
final __serialize() : never
Return values
never__unserialize()
public
final __unserialize(array<string|int, mixed> $data) : never
Parameters
- $data : array<string|int, mixed>
Return values
neverclose()
Closes the resource, marking it as unusable.
public
close() : void
Whether pending operations are aborted or not is implementation dependent.
isClosed()
Returns whether this resource has been closed.
public
isClosed() : bool
Return values
bool —true if closed, otherwise false.
isSupported()
Checks if threading is enabled.
public
static isSupported() : bool
Return values
bool —True if threading is enabled, otherwise false.
join()
public
join([Cancellation|null $cancellation = null ]) : TResult
Parameters
- $cancellation : Cancellation|null = null
Return values
TResult —The data returned from the context. This method may be called at any time to await the result or an exception will be thrown if the context is closed or throws an exception or exits with a non-zero code.
onClose()
Registers a callback that is invoked when this resource is closed.
public
onClose(Closure $onClose) : void
Parameters
- $onClose : Closure
receive()
public
receive([Cancellation|null $cancellation = null ]) : TReceive
Parameters
- $cancellation : Cancellation|null = null
-
Cancels waiting for the next value. Note the next value is not discarded if the operation is cancelled, rather it will be returned from the next call to this method.
Return values
TReceive —Data received.
send()
public
send(mixed $data) : void
Parameters
- $data : mixed
start()
public
static start(IpcHub $ipcHub, string|array<int, string> $script[, Cancellation|null $cancellation = null ][, positive-int $childConnectTimeout = self::DEFAULT_START_TIMEOUT ]) : self
Parameters
- $ipcHub : IpcHub
- $script : string|array<int, string>
-
Path to PHP script or array with first element as path and following elements options to the PHP script (e.g.: ['bin/worker.php', 'Option1Value', 'Option2Value']).
- $cancellation : Cancellation|null = null
- $childConnectTimeout : positive-int = self::DEFAULT_START_TIMEOUT
-
Number of seconds the thread will attempt to connect to the parent before failing.
Tags
Return values
self__clone()
protected
final __clone() : mixed
receiveExitResult()
protected
receiveExitResult([Cancellation|null $cancellation = null ]) : ExitResult
Parameters
- $cancellation : Cancellation|null = null
Return values
ExitResult__construct()
private
__construct(int $id, Runtime $runtime, Future $future, ParallelHub $hub, StreamChannel $ipcChannel, StreamChannel $resultChannel) : mixed
Parameters
- $id : int
- $runtime : Runtime
- $future : Future
- $hub : ParallelHub
- $ipcChannel : StreamChannel
- $resultChannel : StreamChannel