make the refresh time dependant on the time the previous refresh took to complete, multiplied by a factor (currently times two)
this will ensure that we don't spend most of our time refreshing. also, when the backend servers go slow we naturally back off the refresh rate
This commit is contained in:
parent
3f4fae5d99
commit
7923903544
@ -26,7 +26,8 @@ window.MapDataRequest = function() {
|
||||
this.MOVE_REFRESH = 2.5; //refresh time to use after a move
|
||||
this.STARTUP_REFRESH = 1; //refresh time used on first load of IITC
|
||||
this.IDLE_RESUME_REFRESH = 5; //refresh time used after resuming from idle
|
||||
this.REFRESH = 60; //refresh time to use when not idle and not moving
|
||||
this.REFRESH = 60; //minimum refresh time to use when not idle and not moving
|
||||
this.FETCH_TO_REFRESH_FACTOR = 2; //refresh time is based on the time to complete a data fetch, times this value
|
||||
}
|
||||
|
||||
|
||||
@ -77,6 +78,10 @@ window.MapDataRequest.prototype.getStatus = function() {
|
||||
|
||||
window.MapDataRequest.prototype.refresh = function() {
|
||||
|
||||
//time the refresh cycle
|
||||
this.refreshStartTime = new Date().getTime();
|
||||
|
||||
|
||||
this.cache.expire();
|
||||
|
||||
this.debugTiles.reset();
|
||||
@ -149,12 +154,17 @@ window.MapDataRequest.prototype.processRequestQueue = function(isFirstPass) {
|
||||
if (Object.keys(this.tileBounds).length == 0) {
|
||||
this.render.endRenderPass();
|
||||
|
||||
console.log("finished requesting data!");
|
||||
var endTime = new Date().getTime();
|
||||
var duration = (endTime - this.refreshStartTime)/1000;
|
||||
|
||||
console.log("finished requesting data! (took "+duration+" seconds to complete)");
|
||||
|
||||
window.runHooks ('mapDataRefreshEnd', {});
|
||||
|
||||
if (!window.isIdle()) {
|
||||
this.refreshOnTimeout(this.REFRESH);
|
||||
// refresh timer based on time to run this pass, with a minimum of REFRESH seconds
|
||||
var refreshTimer = Math.max(this.REFRESH, duration*this.FETCH_TO_REFRESH_FACTOR);
|
||||
this.refreshOnTimeout(refreshTimer);
|
||||
} else {
|
||||
console.log("suspending map refresh - is idle");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user