2
0
mirror of https://github.com/ACSPRI/queXS synced 2024-04-02 12:12:16 +00:00

Import from DCARF SVN

This commit is contained in:
azammitdcarf
2008-10-15 22:36:05 +00:00
parent 4f0b4f0bbb
commit 1445da495b
2237 changed files with 714445 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
HTML_AJAX_Client_Pool = function(maxClients, startingClients)
{
this.maxClients = maxClients;
this._clients = [];
this._len = 0;
while (--startingClients > 0) {
this.addClient();
}
}
HTML_AJAX_Client_Pool.prototype = {
isEmpty: function()
{
return this._len == 0;
},
addClient: function()
{
if (this.maxClients != 0 && this._len > this.maxClients) {
return false;
}
var key = this._len++;
this._clients[key] = new HTML_AJAX_HttpClient();
return this._clients[key];
},
getClient: function ()
{
for (var i = 0; i < this._len; i++) {
if (!this._clients[i].callInProgress() && this._clients[i].callbackComplete) {
return this._clients[i];
}
}
var client = this.addClient();
if (client) {
return client;
}
return false;
},
removeClient: function (client)
{
for (var i = 0; i < this._len; i++) {
if (!this._clients[i] == client) {
this._clients.splice(i, 1);
return true;
}
}
return false;
},
clear: function ()
{
this._clients = [];
this._len = 0;
}
};
// create a default client pool with unlimited clients
HTML_AJAX.clientPools['default'] = new HTML_AJAX_Client_Pool(0);