Functions and variables available to the doWork function. For instance, the sendProgress(), sendComplete(), and sendError() functions allow returning output.

doWork should exclusively use WorkOutput to communicate with the main thread. On many targets it's also possible to access static or instance variables, but this isn't thread safe and won't work in HTML5.

Variables

activeJob:Null<JobData>

The job that is currently running on this thread, or the job that triggered the ongoing onComplete, onError, or onProgress event. Will be null in all other cases.

read onlymode:ThreadMode

Whether background threads are being/will be used. If threads aren't available on this target, mode will always be SINGLE_THREADED.

@:value(new Tls())read onlyworkIterations:Tls<Int> = new Tls()

Available on Android, Linux, Mac, Windows, iOS

Thread-local storage. Tracks how many times doWork has been called for the current job, including (if applicable) the ongoing call.

In single-threaded mode, it only counts the number of calls this frame. The lower the number, the less accurate ThreadPool.workLoad becomes, but the higher the number, the more overhead there is. As a ballpark estimate, aim for 10-100 iterations.

@:value(new Tls())read onlyworkIterations:Tls<Int> = new Tls()

Available on Flash, HTML5

Thread-local storage. Tracks how many times doWork has been called for the current job, including (if applicable) the ongoing call.

In single-threaded mode, it only counts the number of calls this frame. The lower the number, the less accurate ThreadPool.workLoad becomes, but the higher the number, the more overhead there is. As a ballpark estimate, aim for 10-100 iterations.

Methods

@:value({ transferList : null, message : null })sendComplete(?message:Dynamic, ?transferList:Array<Transferable>):Void

Available on Android, Flash, Linux, Mac, Windows, iOS

Dispatches onComplete on the main thread, with the given message. doWork should return after calling this.

If using web workers, you can also pass a list of transferable objects.

See also:

@:value({ transferList : null, message : null })sendComplete(?message:Dynamic, ?transferList:Array<Transferable>):Void

Available on HTML5

Dispatches onComplete on the main thread, with the given message. doWork should return after calling this.

If using web workers, you can also pass a list of transferable objects.

See also:

@:value({ transferList : null, message : null })sendError(?message:Dynamic, ?transferList:Array<Transferable>):Void

Available on Android, Flash, Linux, Mac, Windows, iOS

Dispatches onError on the main thread, with the given message. doWork should return after calling this.

If using web workers, you can also pass a list of transferable objects.

See also:

@:value({ transferList : null, message : null })sendError(?message:Dynamic, ?transferList:Array<Transferable>):Void

Available on HTML5

Dispatches onError on the main thread, with the given message. doWork should return after calling this.

If using web workers, you can also pass a list of transferable objects.

See also:

@:value({ transferList : null, message : null })sendProgress(?message:Dynamic, ?transferList:Array<Transferable>):Void

Available on Android, Flash, Linux, Mac, Windows, iOS

Dispatches onProgress on the main thread, with the given message. This can be called any number of times per job.

If using web workers, you can also pass a list of transferable objects.

See also:

@:value({ transferList : null, message : null })sendProgress(?message:Dynamic, ?transferList:Array<Transferable>):Void

Available on HTML5

Dispatches onProgress on the main thread, with the given message. This can be called any number of times per job.

If using web workers, you can also pass a list of transferable objects.

See also: