|
ABLE 2.0.0 07/02/2003 10:25:01 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.able.AbleEventQueue
The AbleEventQueue allows events added to this queue to be processed on the caller's thread, or on a separate thread controlled by the event queue itself. The queue can also be used for timed event processing. The asynchronous thread of control allows containing AbleEventListener objects to:
Constructor Summary | |
---|---|
AbleEventQueue(AbleEventQueueProcessor theContainingEventProcessor)
Create a new AbleEventQueue. |
Method Summary | |
---|---|
void |
flushEvents()
Removes all events from the event queue. |
int |
getAbleEventProcessingEnabled()
Returns whether asynchronous ABLE event processing is enabled or disabled. |
AbleEvent |
getEvent()
Remove and return the very next event waiting on the queue. |
long |
getSleepTime()
Returns the current sleep time setting. |
boolean |
isAbleEventPostingEnabled()
Indicates whether asynchronous ABLE event posting is enabled or disabled. |
boolean |
isAbleEventProcessingEnabled()
Indicates whether asynchronous ABLE event processing is enabled or disabled. |
boolean |
isTimerEventProcessingEnabled()
Indicates whether automatic periodic processing is enabled or disabled. |
AbleEvent |
peekEvent()
Return the very next event waiting on the queue, but leave that event on the queue for further processing. |
void |
postEvent(AbleEvent theEvent)
Place an event on the queue for future processing, but only if event posting is enabled. |
void |
resumeProcessingEvents()
Resume the "suspended" asynchronous thread of control. |
void |
run()
Called indirectly by startProcessingEvents() when myEventHandlerThread.start() is invoked within that method. |
void |
setAbleEventProcessingEnabled(int theEnabledFlag)
Specify whether asynchronous ABLE event processing is enabled or disabled. |
void |
setSleepTime(long theSleepTime)
Set the sleep time for the thread's processing loop. |
void |
setTimerEventProcessingEnabled(boolean theEnabledFlag)
Specify whether automatic periodic processing is enabled or disabled. |
int |
size()
Returns the number of events on the event queue. |
void |
startProcessingEvents()
Starts the asynchronous thread of control. |
void |
stopProcessingEvents()
Stops the asynchronous thread of control. |
void |
suspendProcessingEvents()
Temporarily suspend the asynchronous thread of control. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public AbleEventQueue(AbleEventQueueProcessor theContainingEventProcessor)
A reference to the enclosing container is saved so that we can call back to it when new events arrive or the timer expires.
Users must call startProcessingEvents() to create a separate thread which continuously listens for new events to arrive on the queue and/or processes timer expirations. Processing can be suspended and resumed by using suspendProcessingEvents() and resumeProcessingEvents() respectively. The thread can be gracefully killed by calling stopProcessingEvents().
theContainingEventProcessor
- An AbleEventQueueProcessor object that will process
timer and asynchronous Able events. This parameter
must never be null.
Method Detail |
public void run()
run
in interface java.lang.Runnable
public void setSleepTime(long theSleepTime)
If the thread is sleeping when this method is called, the changed sleep time value will not take effect until the timer expires and the thread goes back to sleep.
theSleepTime
- The number of milliseconds for which the thread is to
sleep before it awakes and calls the containing event
listener's processTimerEvent() method.public long getSleepTime()
public void setTimerEventProcessingEnabled(boolean theEnabledFlag)
This method can be used before the asynchronous thread of control is started in order to set the thread loop's initial behavior; the method can also be used while the thread is running to start and stop the behavior.
theEnabledFlag
- Specify true if the thread is to awaken every N
milliseconds and call the containing event listener's
processTimerEvent() method; specify false if no
automatic periodic processing is to take place while
the thread is running.
setSleepTime(long)
,
startProcessingEvents()
public boolean isTimerEventProcessingEnabled()
public void setAbleEventProcessingEnabled(int theEnabledFlag) throws java.lang.IllegalArgumentException
This method can be used before the asynchronous thread of control is started in order to set the thread's initial behavior; the method can also be used while the thread is running to start and stop the behavior.
theEnabledFlag
- Specify one of the following values:
Able.ProcessingEnabled_PostingEnabled
Able.ProcessingEnabled_PostingDisabled
Able.ProcessingDisabled_PostingEnabled
Able.ProcessingDisabled_PostingDisabled
java.lang.IllegalArgumentException
- If the parameter is not a valid value.startProcessingEvents()
public int getAbleEventProcessingEnabled()
Able.ProcessingEnabled_PostingEnabled
Able.ProcessingEnabled_PostingDisabled
Able.ProcessingDisabled_PostingEnabled
Able.ProcessingDisabled_PostingDisabled
public boolean isAbleEventPostingEnabled()
public boolean isAbleEventProcessingEnabled()
public void flushEvents()
Note that unless event Posting is disabled before clearing the event queue, new events may arrive on the queue as soon as it has been cleared!
public int size()
Note that unless both event Posting and event Processing are disabled, the number may be invalid as soon as it is returned.
public void startProcessingEvents()
In this thread, one, two, or no actions can occur, depending on what is enabled (see the related method links):
If the thread is already running, this method is a no-op.
setTimerEventProcessingEnabled(boolean)
,
setAbleEventProcessingEnabled(int)
,
stopProcessingEvents()
,
run()
public void stopProcessingEvents()
Timer event processing and ABLE event processing cease, but if event posting is still enabled, events may still be placed on the internal event queue by other processes. However, events currently on the queue at the time the thread is stopped are flushed! Events placed on the queue after the thread is stopped and the queue is flushed will not be processed until a new thread is started.
If no thread is running, this method is a no-op.
startProcessingEvents()
public void suspendProcessingEvents()
Timer event processing and ABLE event processing cease, but if event Posting is still enabled, events may still be placed on the internal event queue by other processes.
Because the thread may be doing some work at the time this method is called, it may take some time before the thread actually achieves a suspended state. This method will not return until AbleState.Suspended is achieved.
This method must be called synchronously; it cannot be called from the asynchronous thread itself.
If no thread is running, this method is a no-op.
If the thread is already suspended, this method is a no-op.
resumeProcessingEvents()
,
run()
public void resumeProcessingEvents()
Timer event processing and ABLE event processing resume if these actions are enabled.
If no thread is running, this method is a no-op.
If the thread is not suspended, this method is a no-op.
suspendProcessingEvents()
,
run()
public void postEvent(AbleEvent theEvent)
Note that the caller must have the monitor before calling
this method; for example, synchronized (eventQueue) {eventQueue.postEvent(someAbleEvent);}
theEvent
- The event to be processed at some future time.
MonitorStateException
- if the caller does not have the monitor for this event
queue as explained above.getEvent()
,
peekEvent()
public AbleEvent getEvent()
postEvent(AbleEvent)
,
peekEvent()
public AbleEvent peekEvent()
getEvent()
|
ABLE 2.0.0 07/02/2003 10:25:01 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |