mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-05-25 04:04:52 +00:00
48 lines
824 B
JavaScript
48 lines
824 B
JavaScript
// Serialize load (avoid too many parallel connections)
|
|
Ext.define('PVE.data.UpdateQueue', {
|
|
singleton: true,
|
|
|
|
constructor : function(){
|
|
var me = this;
|
|
|
|
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.storeid] = null;
|
|
|
|
idle = false;
|
|
store.load({
|
|
callback: function(records, operation, success) {
|
|
idle = true;
|
|
start_update();
|
|
}
|
|
});
|
|
};
|
|
|
|
Ext.apply(me, {
|
|
queue: function(store) {
|
|
if (!store.storeid) {
|
|
throw "unable to queue store without storeid";
|
|
}
|
|
if (!queue_idx[store.storeid]) {
|
|
queue_idx[store.storeid] = store;
|
|
queue.push(store);
|
|
}
|
|
start_update();
|
|
}
|
|
});
|
|
}
|
|
});
|