Documentation

BulkCurlTask extends AsyncTask
in package

Executes a consecutive list of cURL operations.

The result of this AsyncTask is an array of arrays (returned from ) or InternetException objects.

Table of Contents

TLS_KEY_COMPLETION_CALLBACK  = "completionCallback"
$progressUpdates  : Threaded
$worker  : AsyncWorker|null
$cancelRun  : bool
$crashed  : bool
$finished  : bool
$operations  : string
$result  : scalar|null
$serialized  : bool
$submitted  : bool
$threadLocalStorage  : ArrayObject|array<string|int, mixed>|null
__construct()  : mixed
BulkCurlTask constructor.
__destruct()  : mixed
cancelRun()  : void
getResult()  : mixed
hasCancelledRun()  : bool
hasResult()  : bool
isCrashed()  : bool
isFinished()  : bool
Returns whether this task has finished executing, whether successfully or not. This differs from isRunning() because it is not true prior to task execution.
isSubmitted()  : bool
onCompletion()  : void
Actions to execute when completed (on main thread) Implement this if you want to handle the data in your AsyncTask after it has been processed
onError()  : void
Called from the main thread when the async task experiences an error during onRun(). Use this for things like promise rejection.
onProgressUpdate()  : void
Called from the main thread after {@link AsyncTask::publishProgress} is called.
onRun()  : void
Actions to execute when run
publishProgress()  : void
Call this method from {@link AsyncTask::onRun} (AsyncTask execution thread) to schedule a call to {@link AsyncTask::onProgressUpdate} from the main thread with the given progress parameter.
run()  : void
setResult()  : void
setSubmitted()  : void
fetchLocal()  : mixed
Retrieves data stored in thread-local storage.
reallyDestruct()  : void
Override this to do normal __destruct() cleanup from a child class.
storeLocal()  : void
Saves mixed data in thread-local storage. Data stored using this storage is **only accessible from the thread it was stored on**. Data stored using this method will **not** be serialized.

Constants

TLS_KEY_COMPLETION_CALLBACK

private mixed TLS_KEY_COMPLETION_CALLBACK = "completionCallback"

Properties

$progressUpdates

public Threaded $progressUpdates

$serialized

private bool $serialized = false

$threadLocalStorage

private static ArrayObject|array<string|int, mixed>|null $threadLocalStorage = null

object hash => mixed data

Tags
phpstan-var

\ArrayObject<int, array<string, mixed>>|null

Used to store objects which are only needed on one thread and should not be serialized.

Methods

__construct()

BulkCurlTask constructor.

public __construct(array<string|int, BulkCurlTaskOperation$operations, Closure $onCompletion) : mixed

$operations accepts an array of arrays. Each member array must contain a string mapped to "page", and optionally, "timeout", "extraHeaders" and "extraOpts". Documentation of these options are same as those in .

Parameters
$operations : array<string|int, BulkCurlTaskOperation>
$onCompletion : Closure
Tags
phpstan-param

\Closure(list<InternetRequestResult|InternetException> $results) : void $onCompletion

Return values
mixed

__destruct()

public final __destruct() : mixed
Return values
mixed

cancelRun()

public cancelRun() : void
Return values
void

getResult()

public getResult() : mixed
Return values
mixed

hasCancelledRun()

public hasCancelledRun() : bool
Return values
bool

hasResult()

public hasResult() : bool
Return values
bool

isCrashed()

public isCrashed() : bool
Return values
bool

isFinished()

Returns whether this task has finished executing, whether successfully or not. This differs from isRunning() because it is not true prior to task execution.

public isFinished() : bool
Return values
bool

isSubmitted()

public isSubmitted() : bool
Return values
bool

onCompletion()

Actions to execute when completed (on main thread) Implement this if you want to handle the data in your AsyncTask after it has been processed

public onCompletion() : void
Return values
void

onError()

Called from the main thread when the async task experiences an error during onRun(). Use this for things like promise rejection.

public onError() : void
Return values
void

onProgressUpdate()

Called from the main thread after {@link AsyncTask::publishProgress} is called.

public onProgressUpdate(mixed $progress) : void

All calls should result in calls before is called.

Parameters
$progress : mixed

The parameter passed to . It is serialize()'ed and then unserialize()'ed, as if it has been cloned.

Return values
void

onRun()

Actions to execute when run

public onRun() : void
Return values
void

publishProgress()

Call this method from {@link AsyncTask::onRun} (AsyncTask execution thread) to schedule a call to {@link AsyncTask::onProgressUpdate} from the main thread with the given progress parameter.

public publishProgress(mixed $progress) : void
Parameters
$progress : mixed

A value that can be safely serialize()'ed.

Return values
void

run()

public run() : void
Return values
void

setResult()

public setResult(mixed $result) : void
Parameters
$result : mixed
Return values
void

setSubmitted()

public setSubmitted() : void
Return values
void

fetchLocal()

Retrieves data stored in thread-local storage.

protected fetchLocal(string $key) : mixed

If you used storeLocal(), you can use this on the same thread to fetch data stored. This should be used during onProgressUpdate() and onCompletion() to fetch thread-local data stored on the parent thread.

Parameters
$key : string
Tags
throws
InvalidArgumentException

if no data were stored by this AsyncTask instance.

Return values
mixed

reallyDestruct()

Override this to do normal __destruct() cleanup from a child class.

protected reallyDestruct() : void
Return values
void

storeLocal()

Saves mixed data in thread-local storage. Data stored using this storage is **only accessible from the thread it was stored on**. Data stored using this method will **not** be serialized.

protected storeLocal(string $key, mixed $complexData) : void

This can be used to store references to variables which you need later on on the same thread, but not others.

For example, plugin references could be stored in the constructor of the async task (which is called on the main thread) using this, and then fetched in onCompletion() (which is also called on the main thread), without them becoming serialized.

Scalar types can be stored directly in class properties instead of using this storage.

Objects stored in this storage can be retrieved using fetchLocal() on the same thread that this method was called from.

Parameters
$key : string
$complexData : mixed

the data to store

Return values
void

Search results