|
ABLE, Version 1.1b | |||||||||
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 was, at one time, just that: a simple event queue. Then, an asynchronous thread of control was added to the queue, and later timed event processing was added to that. Therefore, AbleEventQueue is now poorly named. However, it does provide an asynchronous thread of control that allows containing AbleEventListener objects to:
(1) Receive and process asynchronous ABLE events while doing other work. Sequencing of events is enforced.
(2) Perform asynchronous special processing at regular, timed intervals.
(3) Do any combination of (1) and (2). This class in intended to be used by all AbleEventListeners to support the handleAbleEvent() method.
Constructor Summary | |
AbleEventQueue(AbleEventQueueProcessor theContainingEventProcessor)
Create a new AbleEventQueue. |
Method Summary | |
void |
flushEvents()
|
int |
getAbleEventProcessingEnabled()
Determine whether asynchronous ABLE event processing is enabled or disabled. |
AbleEvent |
getEvent()
Remove and return the very next event waiting on the queue. |
long |
getSleepTime()
Retrieve the current sleep time setting. |
boolean |
isAbleEventPostingEnabled()
Determine whether asynchronous ABLE event posting is enabled or disabled. |
boolean |
isAbleEventProcessingEnabled()
Determine whether asynchronous ABLE event processing is enabled or disabled. |
boolean |
isTimerEventProcessingEnabled()
Determine 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()
Determine the number of events on the event queue. |
void |
startProcessingEvents()
Start the asynchronous thread of control. |
void |
stopProcessingEvents()
Stop 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()
public void setSleepTime(long theSleepTime)
Nothing fancy happens here. 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:
startProcessingEvents()
public int getAbleEventProcessingEnabled()
public boolean isAbleEventPostingEnabled()
public boolean isAbleEventProcessingEnabled()
public void flushEvents()
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. Events on the queue 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.
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 the thread is not suspended, this method is a no-op.
suspendProcessingEvents()
,
run()
public void postEvent(AbleEvent theEvent)
theEvent
- The event to be processed at some future time.
getEvent()
,
peekEvent()
public AbleEvent getEvent()
postEvent(AbleEvent)
,
peekEvent()
public AbleEvent peekEvent()
getEvent()
|
ABLE, Version 1.1b | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |