uk.ac.man.bioinf.apps.invoker
Class InvokerInternalQueue

java.lang.Object
  |
  +--uk.ac.man.bioinf.apps.invoker.InvokerInternalQueue
All Implemented Interfaces:
EventListener, Runnable, SystemListener

public class InvokerInternalQueue
extends Object
implements Runnable, SystemListener

InvokerInternalQueue.java This class is used as a helper mechanism for interacting with swing objects. The idea here is that you it you can place an object on this queue, and have a slow method invoked on it in a thread, and then a fast method in the system event queue, without having to worry about the threads themselves. This class originally was originally called SlowInternalQueue but Ive changed it because this was only due to historical reasons anyway. As this class contains an internal thread, with a reference to it, it will not garbage collect by itself. It contains a "destroy()" method which allows graceful shutdown. Once this method has been called on an object any attempt to enqueue to the object will throw an exception.

Created: Mon Dec 07 13:52:32 1998

Compliant:

Version:
Author:
Phillip Lord

Field Summary
 boolean systemClosing
           
 
Fields inherited from interface uk.ac.man.bioinf.apps.systemevents.SystemListener
NO_VETO, VETO_DUE_TO_ERROR, VETO_DUE_TO_USER_REQUEST
 
Constructor Summary
InvokerInternalQueue()
           
InvokerInternalQueue(SystemEventProducer producer)
           
InvokerInternalQueue(SystemEventProducer producer, List queue)
          A new queue.
 
Method Summary
 void destroy()
          Gracefully close down the thread
 void enqueue(AnonInvoker event)
           
 boolean getOneAtATime()
          Get the value of oneAtATime.
 boolean isDestroyed()
           
 void makeEmpty()
           
 void run()
           
 void setOneAtATime(boolean oneAtATime)
          Set the value of oneAtATime.
 void systemEventOccured(SystemEvent e)
          This is an event listener for system events.
 int systemListenerPriority()
          Some events (particularly shut downs) have to happen in a very specific order.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

systemClosing

public boolean systemClosing
Constructor Detail

InvokerInternalQueue

public InvokerInternalQueue()

InvokerInternalQueue

public InvokerInternalQueue(SystemEventProducer producer)

InvokerInternalQueue

public InvokerInternalQueue(SystemEventProducer producer,
                            List queue)
A new queue. This queue will listen for SystemClosing events and will shut down its own thread when it hears this. The list parameter needs to be a list which is mutable. This class does NOT provide any synchronisation for the list, so it needs to be synchronised appropriately. It practice this means it should be fully synchronised!

Parameters:
producer -
queue -
Method Detail

run

public void run()
Specified by:
run in interface Runnable

makeEmpty

public void makeEmpty()

isDestroyed

public boolean isDestroyed()

destroy

public void destroy()
Gracefully close down the thread


enqueue

public void enqueue(AnonInvoker event)

getOneAtATime

public boolean getOneAtATime()
Get the value of oneAtATime.

Returns:
Value of oneAtATime.

setOneAtATime

public void setOneAtATime(boolean oneAtATime)
Set the value of oneAtATime.

Parameters:
oneAtATime - Value to assign to oneAtATime.

systemEventOccured

public void systemEventOccured(SystemEvent e)
Description copied from interface: SystemListener
This is an event listener for system events. All listeners should be signalled before the SystemEvent occurs. They should not return from this method until they are ready for that event to occur. An exception is thrown if the listener wishes to veto this system event. g

Specified by:
systemEventOccured in interface SystemListener
Parameters:
e - the system event occuring

systemListenerPriority

public int systemListenerPriority()
Description copied from interface: SystemListener
Some events (particularly shut downs) have to happen in a very specific order. This method provides a priority to allow this to happen. Those with the lowest priority are informed first. Any valid int value is acceptable. This interface does not provide the ability to set different priorities for different events. The same effect can be achieved by delegating the to a small class. This way a single object can register more than one listener object, and thus have different priorities for different events A listener should not change its priority. There is not guarentee when this value will be used.

Specified by:
systemListenerPriority in interface SystemListener

toString

public String toString()
Overrides:
toString in class Object