public class WorkspaceUpdater
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
(package private) static org.apache.log4j.Logger |
LOGGER
The static logger for the class.
|
Constructor and Description |
---|
WorkspaceUpdater(Workspace workspace)
Constructor for the updater that uses the default controller and default
number of threads.
|
WorkspaceUpdater(Workspace workspace,
int threads)
Constructor for the updater that uses the provided controller and
threads.
|
Modifier and Type | Method and Description |
---|---|
void |
addComponentListener(ComponentUpdateListener listener)
Adds a component listener to this instance.
|
void |
addUpdaterListener(WorkspaceUpdaterListener listener)
Adds an updater listener to this instance.
|
java.util.List<ComponentUpdateListener> |
getComponentListeners()
Return list of component listeners.
|
java.util.List<? extends WorkspaceComponent> |
getComponents()
Get a synchronized list of component.
|
int |
getNumThreads() |
int |
getTime()
Returns the 'time' or number of update iterations that have passed.
|
UpdateActionManager |
getUpdateManager()
Returns a reference to the update manager.
|
java.util.List<WorkspaceUpdaterListener> |
getUpdaterListeners()
Return list of updater listeners.
|
Workspace |
getWorkspace() |
boolean |
isRunning()
Returns whether the updater is set to run.
|
void |
iterate(java.util.concurrent.CountDownLatch latch,
int numIterations)
Iterate a set number of iterations against a latch.
|
void |
iterate(int numIterations)
Iterate the updater for a specified number of iterations.
|
(package private) void |
notifyComponentUpdateFinished(WorkspaceComponent component,
int thread)
Called when a new component is finished updating.
|
(package private) void |
notifyComponentUpdateStarted(WorkspaceComponent component,
int thread)
Called when a new component is starting to update.
|
protected void |
notifyCouplingsUpdated()
Called when the couplings are updated.
|
void |
removeComponentListener(ComponentUpdateListener listener)
Removes a component listener from this instance.
|
void |
removeUpdaterListener(WorkspaceUpdaterListener listener)
Removes an updater listener from this instance.
|
void |
resetTime()
Reset time to 0.
|
void |
run()
Starts the update thread.
|
void |
runOnce()
Submits a single task to the queue.
|
void |
runOnce(java.util.concurrent.CountDownLatch latch)
Submits a single task to the queue, and counts down a latch when done.
|
void |
setNumThreads(int numThreads)
Set number of threads in updater.
|
void |
setTaskSynchronizationManager(TaskSynchronizationManager manager)
Sets the manager.
|
void |
setTime(int time)
Sets the time.
|
void |
stop()
Stops the update thread.
|
void |
updateComponent(WorkspaceComponent component,
CompletionSignal signal)
Update the provided workspace component.
|
void |
updateCouplings()
Update couplings.
|
public WorkspaceUpdater(Workspace workspace, int threads)
workspace
- The parent workspace.threads
- The number of threads for component updates.public WorkspaceUpdater(Workspace workspace)
workspace
- The parent workspace.public void setTaskSynchronizationManager(TaskSynchronizationManager manager)
manager
- the new manager.public int getTime()
public void setTime(int time)
time
- time to setpublic void resetTime()
public void stop()
public boolean isRunning()
public void run()
public void runOnce(java.util.concurrent.CountDownLatch latch)
latch
- the latch to count down.public void runOnce()
public void addComponentListener(ComponentUpdateListener listener)
listener
- The component listener to add.public java.util.List<ComponentUpdateListener> getComponentListeners()
public void removeComponentListener(ComponentUpdateListener listener)
listener
- The listener to add.public void addUpdaterListener(WorkspaceUpdaterListener listener)
listener
- updater component listener to add.public java.util.List<WorkspaceUpdaterListener> getUpdaterListeners()
public void removeUpdaterListener(WorkspaceUpdaterListener listener)
listener
- The updater listener to add.void notifyComponentUpdateStarted(WorkspaceComponent component, int thread)
component
- The component to update.thread
- The number of the thread doing the update.void notifyComponentUpdateFinished(WorkspaceComponent component, int thread)
component
- The component to update.thread
- The number of the thread doing the update.protected void notifyCouplingsUpdated()
public int getNumThreads()
public void setNumThreads(int numThreads)
numThreads
- number of threads.public void iterate(int numIterations)
numIterations
- number of times to iterate updater.public void iterate(java.util.concurrent.CountDownLatch latch, int numIterations)
Workspace.iterate(CountDownLatch, int)
latch
- the latch to count downnumIterations
- the number of iteration to updatepublic UpdateActionManager getUpdateManager()
public java.util.List<? extends WorkspaceComponent> getComponents()
public void updateComponent(WorkspaceComponent component, CompletionSignal signal)
component
- the component to update.signal
- completion signalpublic void updateCouplings()
public Workspace getWorkspace()