QJCC homepage

biz.chitec.quarterback.util
Class AsyncEventDispatcher

java.lang.Object
  extended byjava.lang.Thread
      extended bybiz.chitec.quarterback.util.AsyncEventDispatcher
All Implemented Interfaces:
java.lang.Runnable

public class AsyncEventDispatcher
extends java.lang.Thread

Base thread class for handling GUI-driven events asynchronously from the GUI. This class starts a thread in which synchronous GUI event handlers may continue their execution. This class works by starting a private subthread. That one is listening at a ThreadInterface. It receives AsyncEvents which contain either an AsyncEventHandler or a Runnable. That ones handling method (either AsyncEventHandler.handleAsyncEvent() or Runnable.run()) is executed in the asynchronous thread.

Version:
$Id: 839bd9093ed84591faad4b184353215108108d2a $
Author:
Dirk Hillbrecht 1997-2000, chitec/Dirk Hillbrecht 2000, cantamen/Dirk Hillbrecht 2003,2005 Distributed under the terms of the GNU LGPL.
See Also:
AsyncEvent, AsyncEventHandler

Field Summary
private static AsyncEventThread aet
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
AsyncEventDispatcher()
          May be instanciated for compatibility reasons only, all methods are static.
 
Method Summary
static void assertAsyncDispatchingThread()
          Tests whether called in event dispatching thread.
static void invoke(AsyncEventHandler target)
           
static void invoke(java.util.EventObject e, AsyncEventHandler target)
           
static void invoke(java.lang.Runnable target)
           
static void invokeIfSleeping(AsyncEventHandler target)
           
static void invokeIfSleeping(java.util.EventObject e, AsyncEventHandler target)
           
static void invokeIfSleeping(java.lang.Runnable target)
           
static void invokeIfSleeping(java.lang.Runnable target, java.lang.Runnable alternative)
          Calls target in async thread if that one is free or alternative in current thread.
static void invokeLater(java.lang.Runnable target)
           
static boolean isAsyncDispatchThread()
          Returns true if running in the asynchronous dispatching thread handled by this class.
static void sendEvent(AsyncEvent ae)
           
static void sendEvent(AsyncEventHandler target)
           
static void sendEvent(java.util.EventObject e, AsyncEventHandler target)
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

aet

private static AsyncEventThread aet
Constructor Detail

AsyncEventDispatcher

public AsyncEventDispatcher()
May be instanciated for compatibility reasons only, all methods are static.

Method Detail

isAsyncDispatchThread

public static boolean isAsyncDispatchThread()
Returns true if running in the asynchronous dispatching thread handled by this class. Use this call to ensure that a given task is (not) being executed on the asynchronous dispatching thread.

Returns:
true if running on the asynchronous dispatching thread

assertAsyncDispatchingThread

public static void assertAsyncDispatchingThread()
Tests whether called in event dispatching thread. Prints stack trace if not.


sendEvent

public static void sendEvent(AsyncEvent ae)

sendEvent

public static void sendEvent(AsyncEventHandler target)

sendEvent

public static void sendEvent(java.util.EventObject e,
                             AsyncEventHandler target)

invoke

public static void invoke(AsyncEventHandler target)

invoke

public static void invoke(java.util.EventObject e,
                          AsyncEventHandler target)

invokeIfSleeping

public static void invokeIfSleeping(AsyncEventHandler target)

invokeIfSleeping

public static void invokeIfSleeping(java.util.EventObject e,
                                    AsyncEventHandler target)

invoke

public static void invoke(java.lang.Runnable target)

invokeLater

public static void invokeLater(java.lang.Runnable target)

invokeIfSleeping

public static void invokeIfSleeping(java.lang.Runnable target)

invokeIfSleeping

public static void invokeIfSleeping(java.lang.Runnable target,
                                    java.lang.Runnable alternative)
Calls target in async thread if that one is free or alternative in current thread. target is executed in asynchronous thread, but only if asynchronous thread is currently idleing. Otherwise (asynchronous thread is currently executing another Runnable), alternative is executed in current thread and target is not executed at all.


QJCC homepage