| Language Version : | ActionScript 3.0 |
| Product Version : | Portfolio 10.0 |
| Runtime Versions : | Flash Player 10.1, AIR 2.0 |
The JobUtil class implements a job queue that runs jobs sequentially.
JobUtil implements a FILO (first-in, last out) queue that is particularly useful for deferred computation of list display elements.
It can also be used for deferred tasks that need to be done serially.
A FILO model allows clients to continually push the highest priority jobs. The idea is that the most recent events a
have the higest priority. A job already on the queue that is "re-pushed" will
will be promoted to the top of the queue.
Imagine a large list of visual elements, which may take substantial computation to display (at least initially).
The list can use JobUtil to queue the work to compute the visual representation. Meanwhile, the user may start scrolling
to arbitrary sections of the list. By repushing the elements in the current view, the elements get re-prioritized to
compute before other non-visible items. This process may repeat, as the user scrolls to various random views of
the list. Because of this model, it's ideal to push the visual elements in reverse order if the initial view is
of the first part of the list. Another strategy is to simply repush any elements that are currently visible.
Using JobUtil allows the client control over the priority of the deferred work to be done and prevents the UI from
"locking up" by using timers. In many respects it's equivalent to spawning a separate thread in multi-threaded
environments, but without the syncronization headaches.