HTML and CSS Reference
In-Depth Information
creating a pool that can be used in a round-robin fashion so that not too many workers are
created.
DOM access
Workers operate in their own global context, which means that they don't have access to the
DOM of the page that invoked them. The DOM shouldn't be manipulated from a worker pro-
cess. The worker context has no access to the window object, document object, or any parent
object.
Subworkers
Following the same patterns as for a worker from the main webpage, a worker can create
workers as well. All constructs must be followed for passing data and getting data returned.
However, knowing how many total workers will be created becomes increasingly important.
Coniguring timeouts and intervals
You can set up a web worker to run on a specified interval in the background. This is done by
using any existing setTimeout or setInterval methods. The setTimeout method calls a specified
function after the specified delay. The setInterval calls the specified function repeatedly after
each specified time interval. For example, the following code runs the worker after 3 seconds:
var work = new Worker("workerFile.js");
setTimeout(function(){
work.postMessage("");
},3000);
However, the following code runs the worker every 3 seconds:
var work = new Worker("workerFile.js");
setInterval(function(){
work.postMessage("");
},3000);
 
 
Search WWH ::




Custom Search