From: Henri Sara Date: Wed, 18 Jan 2012 09:04:52 +0000 (+0200) Subject: Defer sending of changes from client to server to group them. X-Git-Tag: 7.0.0.alpha2~440^2~42 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5349e3c5a60dcb05842729542153822edbf6c450;p=vaadin-framework.git Defer sending of changes from client to server to group them. --- diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java index f8ca0a6959..af3fcefaf2 100644 --- a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java +++ b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java @@ -17,6 +17,7 @@ import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JsArray; import com.google.gwt.core.client.JsArrayString; import com.google.gwt.core.client.Scheduler; +import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.http.client.Request; import com.google.gwt.http.client.RequestBuilder; import com.google.gwt.http.client.RequestCallback; @@ -1133,8 +1134,23 @@ public class ApplicationConnection { * "burst" to queue that will be purged after current request is handled. * */ - @SuppressWarnings("unchecked") public void sendPendingVariableChanges() { + if (!deferedSendPending) { + deferedSendPending = true; + Scheduler.get().scheduleDeferred(sendPendingCommand); + } + } + + private final ScheduledCommand sendPendingCommand = new ScheduledCommand() { + public void execute() { + deferedSendPending = false; + doSendPendingVariableChanges(); + } + }; + private boolean deferedSendPending = false; + + @SuppressWarnings("unchecked") + private void doSendPendingVariableChanges() { if (applicationRunning) { if (hasActiveRequest()) { // skip empty queues if there are pending bursts to be sent