Class DecoupledEventProcessor
- All Implemented Interfaces:
EventProcessor
BlockingQueue
.-
Field Summary
Fields inherited from interface swingtree.threading.EventProcessor
COUPLED, COUPLED_STRICT, DECOUPLED
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
join()
A fully blocking call to the decoupled thread event processor causing this thread to join its event queue so that it can continuously process events produced by the UI.void
joinFor
(long numberOfEvents) A fully blocking call to the decoupled thread event processor causing this thread to join its event queue so that it can process the given number of events produced by the UI.void
A temporarily blocking call to the decoupled thread event processor causing this thread to join its event queue so that it can continuously process events produced by the UI until all events have been processed or an exception is thrown by the event processor.void
A fully blocking call to the decoupled thread event processor causing this thread to join its event queue so that it can continuously process events produced by the UI.void
joinUntilExceptionFor
(long numberOfEvents) A temporarily blocking call to the decoupled thread event processor causing this thread to join its event queue so that it can process the given number of events produced by the UI.void
registerAndRunAppEventNow
(Runnable runnable) Adds the supplied task to an event queue for processing application events and then waits for the task to be processed on the application thread.void
registerAndRunUIEventNow
(Runnable runnable) Adds the supplied task to an event queue for processing UI events and then waits for the task to be processed on the GUI thread.void
registerAppEvent
(Runnable task) Adds the supplied task to an event queue for processing application events.void
registerUIEvent
(Runnable runnable) Adds the supplied task to an event queue for processing UI events.
-
Constructor Details
-
DecoupledEventProcessor
public DecoupledEventProcessor()
-
-
Method Details
-
registerAppEvent
Description copied from interface:EventProcessor
Adds the supplied task to an event queue for processing application events. The task is executed in the application thread, which may be the GUI thread (but shouldn't be if you are doing clean software development). This method returns immediately.- Specified by:
registerAppEvent
in interfaceEventProcessor
- Parameters:
task
- The task to be executed in the application thread.
-
registerAndRunAppEventNow
Description copied from interface:EventProcessor
Adds the supplied task to an event queue for processing application events and then waits for the task to be processed on the application thread. The task is executed in the application thread, which, depending on your implementation, may also be the GUI thread (but shouldn't be if you are doing clean software development). This method returns when the task has been processed.- Specified by:
registerAndRunAppEventNow
in interfaceEventProcessor
- Parameters:
runnable
- The task to be executed in the application thread.
-
registerUIEvent
Description copied from interface:EventProcessor
Adds the supplied task to an event queue for processing UI events. The task is executed in the GUI thread, which is the EDT in Swing. This method returns immediately.- Specified by:
registerUIEvent
in interfaceEventProcessor
- Parameters:
runnable
- The task to be executed in the GUI thread.
-
registerAndRunUIEventNow
Description copied from interface:EventProcessor
Adds the supplied task to an event queue for processing UI events and then waits for the task to be processed on the GUI thread. The task is executed in the GUI thread, which is the EDT in Swing. This method returns when the task has been processed.- Specified by:
registerAndRunUIEventNow
in interfaceEventProcessor
- Parameters:
runnable
- The task to be executed in the GUI thread.
-
join
public void join()A fully blocking call to the decoupled thread event processor causing this thread to join its event queue so that it can continuously process events produced by the UI.This method wither be called by the main thread of the application after the UI has been built and shown to the user, or alternatively a new thread dedicated to processing events. (things like button clicks, etc.)
- Throws:
IllegalStateException
- If this method is called from the UI thread.
-
joinUntilException
A fully blocking call to the decoupled thread event processor causing this thread to join its event queue so that it can continuously process events produced by the UI.This method should be called by the main thread of the application after the UI has been built and shown to the user, or alternatively a new thread dedicated to processing events. (things like button clicks, etc.)
This method will block until an exception is thrown by the event processor. This is useful for debugging purposes.
- Throws:
InterruptedException
- If the thread is interrupted while waiting for the event processor to join.
-
joinFor
public void joinFor(long numberOfEvents) A fully blocking call to the decoupled thread event processor causing this thread to join its event queue so that it can process the given number of events produced by the UI.This method should be called by the main thread of the application after the UI has been built and shown to the user, or alternatively a new thread dedicated to processing events. (things like button clicks, etc.)
This method will block until the given number of events have been processed.
- Parameters:
numberOfEvents
- The number of events to wait for.
-
joinUntilExceptionFor
A temporarily blocking call to the decoupled thread event processor causing this thread to join its event queue so that it can process the given number of events produced by the UI.This method should be called by the main thread of the application after the UI has been built and shown to the user, or alternatively a new thread dedicated to processing events. (things like button clicks, etc.)
This method will block until the given number of events have been processed or an exception is thrown by the event processor.
- Parameters:
numberOfEvents
- The number of events to wait for.- Throws:
InterruptedException
- If the thread is interrupted while waiting for the event processor to join.
-
joinUntilDoneOrException
A temporarily blocking call to the decoupled thread event processor causing this thread to join its event queue so that it can continuously process events produced by the UI until all events have been processed or an exception is thrown by the event processor.This method should be called by the main thread of the application after the UI has been built and shown to the user, or alternatively a new thread dedicated to processing events. (things like button clicks, etc.)
- Throws:
InterruptedException
- If the thread is interrupted while waiting.
-