parallel-debug.js revision 16dc9aab6798bb50c391d6a5dd99c16ae95f501f
/**
* A concurrent parallel processor to help in running several async functions.
* @module parallel
* @main parallel
*/
/**
A concurrent parallel processor to help in running several async functions.
@class Parallel
@example
var stack = new Y.Parallel();
for (var i = 0; i < 15; i++) {
on: {
success: stack.add(function() {
Y.log('Done!');
})
}
});
}
stack.done(function() {
Y.log('All IO requests complete!');
});
@param {Object} o A config object
@param {Object} [o.context=Y] The execution context of the callback to done
*/
Y.Parallel = function(o) {
this.config = o || {};
this.results = [];
this.total = 0;
this.finished = 0;
};
/**
* An Array of results from all the callbacks in the stack
* @property {Array} results
* @private
*/
results: null,
/**
* The total items in the stack
* @property {Number} total
* @private
*/
total: null,
/**
* The number of stacked callbacks executed
* @property {Number} finished
* @private
*/
finished: null,
/**
* Add a callback to the stack
* @method add
* @param {Function} fn The function callback we are waiting for
*/
var self = this;
return function () {
}
},
/**
* Test to see if all registered items in the stack have completed, if so call the callback to `done`
* @method test
*/
test: function () {
var self = this;
}
},
/**
* The method to call when all the items in the stack are complete.
* @method done
* @param {Function} callback The callback to execute on complete
* @param {Mixed} callback.results The results of all the callbacks in the stack
* @param {Mixed} [callback.data] The data given to the `done` method
* @param {Mixed} data Mixed data to pass to the success callback
*/
this.test();
}
};