HTML and CSS Reference
In-Depth Information
FIguRE 10.2 Everything you
could ever need: prime number
and drawing executed without
interruption thanks to Web
Matryoshka dolls: workers
inside workers
If you had a watchful eye, you would have spotted that you can
also create new workers from within a worker. Currently, only
Firefox and Opera support this, but it's part of the spec, so you
should expect that other browsers will be updated to include
this feature.
What this means is that you could spawn one worker, which then
goes and splits its job into lots of delegated little jobs and passes
them to sub-workers. Let's go back to the example of applying
a complex filter to a photo in your super-sexy online image web
app. To speed up the processing of the image—assuming it made
sense in the filter—you could split the image up into regions and
pass each region of image data to a sub-worker.
As each worker returns, you reduce the pending count and,
once all the workers have finished, the main worker returns the
final processed image data to the parent document. It looks
something like this (I've left out some functions from the listing
as this is just to demonstrate the idea):
Search WWH ::

Custom Search