Packageflash.system
Classpublic final class WorkerDomain
InheritanceWorkerDomain Inheritance Object

Language version: ActionScript 3.0
Runtime version: AIR 3.4

The WorkerDomain class provides a way to create Worker objects and access them. A WorkerDomain represents the runtime's mechanism for managing the set of workers within a security domain.

Note: The use of workers for concurrency is supported in both Flash Player and AIR on desktop platforms. For mobile platforms, concurrency is supported in AIR on Android but not in AIR on iOS. You can use the static isSupported property to check whether concurrency is supported before attempting to use it.

You do not create WorkerDomain instances directly by calling the WorkerDomain() constructor. There is one single WorkerDomain instance for an application. In contexts where the use of workers for concurrency is supported, the runtime automatically creates the WorkerDomain at startup. You access that instance using the static current property.

To create a new instance of the Worker class, use the createWorker() method. To access the set of Worker objects that are currently running, use the listWorkers() method.

See also

flash.system.Worker


Public Properties
 PropertyDefined by
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  current : WorkerDomain
[static][read-only] The WorkerDomain instance in which the code is currently running.
WorkerDomain
  isSupported : Boolean
[static][read-only] Indicates whether the current runtime context supports the WorkerDomain and Worker objects for concurrent code execution.
WorkerDomain
 Inheritedprototype : Object
[static] A reference to the prototype object of a class or function object.
Object
Public Methods
 MethodDefined by
  
createWorker(swf:ByteArray, giveAppPrivileges:Boolean = false):Worker
Creates a new Worker instance from the bytes of a swf.
WorkerDomain
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
  
Provides access to the set of workers in the WorkerDomain that are currently running (the Worker instance's state property is WorkerState.RUNNING).
WorkerDomain
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
Returns the string representation of this object, formatted according to locale-specific conventions.
Object
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
Property detail
currentproperty
current:WorkerDomain  [read-only]

Language version: ActionScript 3.0
Runtime version: AIR 3.4

The WorkerDomain instance in which the code is currently running. This is the only WorkerDomain in the application.

Implementation
    public static function get current():WorkerDomain
isSupportedproperty 
isSupported:Boolean  [read-only]

Language version: ActionScript 3.0
Runtime version: AIR 3.4

Indicates whether the current runtime context supports the WorkerDomain and Worker objects for concurrent code execution.

If concurrency is available, this property's value is true.

Implementation
    public static function get isSupported():Boolean
Method detail
createWorker()method
public function createWorker(swf:ByteArray, giveAppPrivileges:Boolean = false):Worker

Language version: ActionScript 3.0
Runtime version: AIR 3.4

Creates a new Worker instance from the bytes of a swf.

Each worker is created from and executes as an isolated swf application. To create a Worker instance, you obtain the bytes of the SWF file as a ByteArray instance and pass it to this method. There are three common ways to access the bytes of a swf for this purpose:

Creating a Worker object using createWorker() does not start execution of the worker. To start a worker's code execution, call the Worker object's start() method.

Workers are useful because they decrease the chances of the frame rate dropping due to the main rendering thread being blocked by other code. However, workers require additional system memory and CPU use, which can be costly to overall application performance. Because each worker uses its own instance of the runtime virtual machine, even the overhead of a trivial worker can be large. When using workers, test your code across all your target platforms to ensure that the demands on the system are not too large. Adobe recommends that you do not use more than one or two background workers in a typical scenario.

Parameters
swf:ByteArray — A ByteArray containing the bytes of a valid swf
 
giveAppPrivileges:Boolean (default = false) — indicates whether the worker should be given application sandbox privileges in AIR. This parameter is ignored in Flash Player

Returns
Worker — the newly created Worker if creation succeeds. A return value of null indicates that a worker could not be created either because the current context doesn't support concurrency or because creating a new worker would exceed implementation limits.

Throws
SecurityError — if the swf whose bytes are passed to the swf parameter is from a different security domain than the swf in which this method is called
listWorkers()method 
public function listWorkers():Vector.<Worker>

Language version: ActionScript 3.0
Runtime version: AIR 3.4

Provides access to the set of workers in the WorkerDomain that are currently running (the Worker instance's state property is WorkerState.RUNNING).

Returns
Vector.<Worker> — A Vector of Worker instances containing the workers that are currently running.