aboutsummaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorMatti Tahvonen <matti.tahvonen@itmill.com>2011-07-16 14:06:36 +0000
committerMatti Tahvonen <matti.tahvonen@itmill.com>2011-07-16 14:06:36 +0000
commit9f3d8a400d8f1109f265d96a4e74321d06cd78a5 (patch)
treec4a521c1e482d61099f0ccf336df16f4c28bac8f /src/com
parentd0d4e75049fe9b4d87f883ae3e14ef705ab02841 (diff)
downloadvaadin-framework-9f3d8a400d8f1109f265d96a4e74321d06cd78a5.tar.gz
vaadin-framework-9f3d8a400d8f1109f265d96a4e74321d06cd78a5.zip
deferred widgetloading is now less eager (slow connection previously flooded loading that should happen controlled)
svn changeset:19801/svn branch:6.6
Diffstat (limited to 'src/com')
-rw-r--r--src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java40
1 files changed, 33 insertions, 7 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java b/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java
index 4b6194b79b..6787b36022 100644
--- a/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java
+++ b/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java
@@ -223,7 +223,6 @@ public class ApplicationConfiguration implements EntryPoint {
}
}
- deferredWidgetLoadLoop.scheduleRepeating(100);
}
/**
@@ -257,6 +256,7 @@ public class ApplicationConfiguration implements EntryPoint {
runningApplications.add(a);
return true;
} else {
+ deferredWidgetLoader = new DeferredWidgetLoader();
return false;
}
}
@@ -361,6 +361,8 @@ public class ApplicationConfiguration implements EntryPoint {
cmd.execute();
}
callbacks.clear();
+ } else if(widgetsLoading == 0 && deferredWidgetLoader != null) {
+ deferredWidgetLoader.trigger();
}
}
@@ -368,22 +370,44 @@ public class ApplicationConfiguration implements EntryPoint {
/*
* This loop loads widget implementation that should be loaded deferred.
*/
- private static final Timer deferredWidgetLoadLoop = new Timer() {
+ static class DeferredWidgetLoader extends Timer {
private static final int FREE_LIMIT = 4;
+ private static final int FREE_CHECK_TIMEOUT = 100;
int communicationFree = 0;
int nextWidgetIndex = 0;
+ private boolean pending;
+
+ public DeferredWidgetLoader() {
+ schedule(5000);
+ }
+
+ public void trigger() {
+ if(!pending) {
+ schedule(FREE_CHECK_TIMEOUT);
+ }
+ }
+
+ @Override
+ public void schedule(int delayMillis) {
+ super.schedule(delayMillis);
+ pending = true;
+ }
@Override
public void run() {
+ pending = false;
if (!isBusy()) {
Class<? extends Paintable> nextType = getNextType();
if (nextType == null) {
// ensured that all widgets are loaded
- cancel();
+ deferredWidgetLoader = null;
} else {
+ communicationFree = 0;
widgetSet.loadImplementation(nextType);
}
+ } else {
+ schedule(FREE_CHECK_TIMEOUT);
}
}
@@ -400,21 +424,23 @@ public class ApplicationConfiguration implements EntryPoint {
private boolean isBusy() {
if (widgetsLoading > 0) {
communicationFree = 0;
- return false;
+ return true;
}
for (ApplicationConnection app : runningApplications) {
if (app.hasActiveRequest()) {
// if an UIDL request or widget loading is active, mark as
// busy
communicationFree = 0;
- return false;
+ return true;
}
}
communicationFree++;
return communicationFree < FREE_LIMIT;
}
- };
-
+ }
+
+ private static DeferredWidgetLoader deferredWidgetLoader;
+
public void onModuleLoad() {
// Enable IE6 Background image caching