[pve-devel] r5501 - pve-manager/pve2/www/manager/data
svn-commits at proxmox.com
svn-commits at proxmox.com
Thu Feb 10 11:32:58 CET 2011
Author: dietmar
Date: 2011-02-10 11:32:58 +0100 (Thu, 10 Feb 2011)
New Revision: 5501
Modified:
pve-manager/pve2/www/manager/data/UpdateStore.js
Log:
Serialize load (avoid too many parallel connections)
Modified: pve-manager/pve2/www/manager/data/UpdateStore.js
===================================================================
--- pve-manager/pve2/www/manager/data/UpdateStore.js 2011-02-10 09:35:53 UTC (rev 5500)
+++ pve-manager/pve2/www/manager/data/UpdateStore.js 2011-02-10 10:32:58 UTC (rev 5501)
@@ -1,5 +1,42 @@
Ext.ns("PVE.data");
+// Serialize load (avoid too many parallel connections)
+PVE.data.UpdateQueue = function() {
+
+ var queue = [];
+ var queue_idx = {};
+
+ var idle = true;
+
+ var start_update = function() {
+ if (!idle)
+ return;
+ var store = queue.shift();
+ if (!store)
+ return;
+
+ queue_idx[store.itype] = null;
+
+ idle = false;
+ store.load({
+ callback: function() {
+ idle = true;
+ start_update();
+ }
+ });
+ };
+
+ return {
+ queue: function(store) {
+ if (queue_idx[store.itype])
+ return;
+ queue_idx[store.itype] = store;
+ queue.push(store);
+ start_update();
+ }
+ };
+}();
+
PVE.data.UpdateStore = Ext.extend(Ext.data.JsonStore, {
constructor: function(config) {
@@ -10,8 +47,7 @@
var run_load_task = function(delay) {
if (!load_task) {
load_task = new Ext.util.DelayedTask(function() {
- //console.log("LOAD " + self.itype);
- self.load();
+ PVE.data.UpdateQueue.queue(self);
});
}
More information about the pve-devel
mailing list