Package com.google.gwt.user.client
Class CommandExecutor
- java.lang.Object
-
- com.google.gwt.user.client.CommandExecutor
-
class CommandExecutor extends java.lang.Object
Class which executesCommand
s andIncrementalCommand
s after all currently pending event handlers have completed. This class attempts to protect against slow script warnings by running commands in small time increments.It is still possible that a poorly written command could cause a slow script warning which a user may choose to cancel. In that event, a
TODO(mmendez): Can an SSW be detected without using a timer? Currently, if aCommandCanceledException
or anIncrementalCommandCanceledException
is reported throughGWT#reportUncaughtException
depending on the type of command which caused the warning. All other commands will continue to be executed.Command
or anIncrementalCommand
calls eitherWindow.alert(String)
or the JavaScriptalert(String)
methods directly or indirectly then the cancellation timer can fire, resulting in a false SSW cancellation detection.
-
-
Constructor Summary
Constructors Constructor Description CommandExecutor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
doCommandCanceled()
Removes the command from the queue and throws either aCommandCanceledException
or anIncrementalCommandCanceledException
depending on type of the command.protected void
doExecuteCommands(double startTimeMillis)
This method will dispatch commands from the command queue.(package private) java.util.List<java.lang.Object>
getPendingCommands()
This method is for testing only.protected void
maybeStartExecutionTimer()
Starts the dispatch timer if there are commands to dispatch and we are not waiting for a dispatch timer and we are not actively dispatching.(package private) void
setExecuting(boolean executing)
This method is for testing only.(package private) void
setLast(int last)
This method is for testing only.void
submit(Command command)
Submits aCommand
for execution.void
submit(IncrementalCommand command)
Submits anIncrementalCommand
for execution.
-
-
-
Method Detail
-
submit
public void submit(Command command)
Submits aCommand
for execution.- Parameters:
command
- command to submit
-
submit
public void submit(IncrementalCommand command)
Submits anIncrementalCommand
for execution.- Parameters:
command
- command to submit
-
doCommandCanceled
protected void doCommandCanceled()
Removes the command from the queue and throws either aCommandCanceledException
or anIncrementalCommandCanceledException
depending on type of the command.
-
doExecuteCommands
protected void doExecuteCommands(double startTimeMillis)
This method will dispatch commands from the command queue. It will dispatch commands until one of the following conditions istrue
:- It consumed its dispatching time slice 100
- It encounters a
null
in the command queue - All commands which were present at the start of the dispatching have been removed from the command queue
- The command that it was processing was canceled due to a false cancellation -- in this case we exit without updating any state
- Parameters:
startTimeMillis
- the time when this method started
-
maybeStartExecutionTimer
protected void maybeStartExecutionTimer()
Starts the dispatch timer if there are commands to dispatch and we are not waiting for a dispatch timer and we are not actively dispatching.
-
getPendingCommands
java.util.List<java.lang.Object> getPendingCommands()
This method is for testing only.
-
setExecuting
void setExecuting(boolean executing)
This method is for testing only.
-
setLast
void setLast(int last)
This method is for testing only.
-
-