2
YUI 3.13.0 (build 508226d)
3
Copyright 2013 Yahoo! Inc. All rights reserved.
4
Licensed under the BSD License.
5
http://yuilibrary.com/license/
8
YUI.add('io-queue', function (Y, NAME) {
11
Extends IO to implement Queue for synchronous
12
transaction processing.
17
var io = Y.io._map['io:0'] || new Y.IO();
19
Y.mix(Y.IO.prototype, {
21
* Array of transactions queued for processing
33
* Property to determine whether the queue is set to
34
* 1 (active) or 0 (inactive). When inactive, transactions
35
* will be stored in the queue until the queue is set to active.
45
* Method Process the first transaction from the
46
* queue in FIFO order.
58
io.send(o.uri, o.cfg, o.id);
62
* Method for queueing a transaction before the request is sent to the
63
* resource, to ensure sequential processing.
69
queue: function(uri, c) {
71
o = { uri: uri, cfg:c, id: this._id++ };
74
Y.on('io:complete', function(id, o) { io._qNext(id); }, io);
79
if (io._qState === 1) {
86
_qNext: function(id) {
89
if (io._qActiveId === id && io._q.size() > 0) {
95
* Method for promoting a transaction to the top of the queue.
100
qPromote: function(o) {
105
* Method for removing a specific, pending transaction from
112
qRemove: function(o) {
117
* Method for cancel all pending transaction from
125
this._q = new Y.Queue();
132
if (io._q.size() > 0) {
138
* Method for setting queue processing to inactive.
139
* Transaction requests to YUI.io.queue() will be stored in the queue, but
140
* not processed until the queue is reset to "active".
151
* Method to query the current size of the queue.
159
return this._q.size();
164
function _queue(u, c) {
165
return io.queue.apply(io, [u, c]);
168
_queue.start = function () { io.qStart(); };
169
_queue.stop = function () { io.qStop(); };
170
_queue.promote = function (o) { io.qPromote(o); };
171
_queue.remove = function (o) { io.qRemove(o); };
172
_queue.size = function () { io.qSize(); };
173
_queue.empty = function () { io.qEmpty(); };
177
}, '3.13.0', {"requires": ["io-base", "queue-promote"]});