new geo.fetchQueue(options){geo.fetchQueue}
This class implements a queue for Deferred objects. Whenever one of the objects in the queue completes (resolved or rejected), another item in the queue is processed. The number of concurrently processing items can be adjusted.
At this time (2018-11-02) most major browsers support 6 concurrent requests from any given server, so, when using the queue for tile images, the number of concurrent requests should be 6 * (number of subdomains serving tiles).
Name | Type | Description |
---|---|---|
options |
geo.fetchQueue.spec |
optional
A configuration object for the queue. |
Returns:
Type | Description |
---|---|
geo.fetchQueue |
Type Definitions
-
geo.fetchQueue.specobject
-
Properties:
Name Type Argument Default Description size
number <optional>
6 The maximum number of concurrent deferred objects.
track
number <optional>
600 The number of objects that are tracked that trigger checking if any of them have been abandoned. The fetch queue can grow to the greater of this size and the number of items that are still needed. Setting this to a low number will increase processing time, to a high number can increase memory. Ideally, it should reflect the number of items that are kept in memory elsewhere. If
needed
isnull
, this is ignored.needed
function <optional>
null If set, this function is passed a Deferred object and must return a truthy value if the object is still needed.
Members
-
initialSize
-
Get/set the initial maximum concurrent deferred object size.
Properties:
Name Type Description initialSize
number The initial maximum number of deferred objects.
0
to usesize
. -
intitialTrack
-
Get/set the initial track size. Unless changed, this is the value used for track on class initialization.
Properties:
Name Type Description initialTrack
number The number of entries to track without checking for discards.
-
length
-
Get the current queue size. Read only.
Properties:
Name Type Description length
number The current queue size.
-
processing
-
Get the current number of processing items. Read only.
Properties:
Name Type Description processing
number The current number of processing items.
-
size
-
Get/set the maximum concurrent deferred object size.
Properties:
Name Type Description size
number The maximum number of deferred objects.
-
track
-
Get/set the track size. This is used to determine when to check if entries can be discarded.
Properties:
Name Type Description track
number The number of entries to track without checking for discards.
Methods
-
add(defer, callback, atEnd){jQuery.Deferred}
-
Add a Deferred object to the queue.
Name Type Description defer
jQuery.Deferred Deferred object to add to the queue.
callback
function A function to call when the item's turn is granted.
atEnd
boolean If falsy, add the item to the front of the queue if batching is turned off or at the end of the current batch if it is turned on. If truthy, always add the item to the end of the queue.
Returns:
Type Description jQuery.Deferred The deferred object that was passed to the function. -
batch(start){number|boolean|this}
-
Start a new batch or clear using batches.
Name Type Description start
boolean Truthy to start a new batch, falsy to turn off using batches.
undefined
to return the current state of batches.Returns:
Type Description number | boolean | this false
if batches are turned off, the batch number if turned on, orthis
if setting the batch. -
clear(){this}
-
Remove all items from the queue.
Returns:
Type Description this -
get(defer){number}
-
Get the position of a deferred object in the queue.
Name Type Description defer
jQuery.Deferred Deferred object to get the position of.
Returns:
Type Description number -1 if not in the queue, or the position in the queue. -
next_item()
-
Check if any items are queued and if the processing allotment is not full. If so, process more items.
-
remove(defer){boolean}
-
Remove a Deferred object from the queue.
Name Type Description defer
jQuery.Deferred Deferred object to add to the queue.
Returns:
Type Description boolean true
if the object was removed.