nsIThreadObserver
From MDC
This article covers features introduced in Firefox 3
The nsIThreadObserver interface may be implemented to let an observer implement a layered event queue.
For example, it's possible to overlay processing events for a GUI toolkit on top of the events for a thread:
var NativeQueue;
Observer = {
onDispatchedEvent(thread) {
NativeQueue.signal();
}
onProcessNextEvent(thread, mayWait, recursionDepth) {
if (NativeQueue.hasNextEvent()) {
NativeQueue.processNextEvent();
}
while (mayWait && !thread.hasPendingEvent()) {
NativeQueue.wait();
NativeQueue.processNextEvent();
}
}
};
Inherits from: nsISupports
Contents |
nsIThreadObserver is defined in xpcom/threads/nsIThreadInternal.idl. It is scriptable and
unfrozen (hasn't changed since Mozilla 1.9).
[edit] Method overview
void onDispatchedEvent(in nsIThreadInternal thread);
|
void onProcessNextEvent(in nsIThreadInternal thread, in boolean mayWait, in unsigned long recursionDepth);
|
void afterProcessNextEvent(in nsIThreadInternal thread, in unsigned long recursionDepth);
|
[edit] Methods
[edit] onDispatchedEvent()
Called after an event has been dispatched to the thread. This method may be called from any thread.
void onDispatchedEvent( in nsIThreadInternal thread )
[edit] Parameters
- thread
- The
nsIThreadon which the event was dispatched.
[edit] onProcessNextEvent()
Called by the nsIThread method processNextEvent() before an event is processed. This method is only called on the target thread.
void onProcessNextEvent( in nsIThreadInternal thread, in boolean mayWait, in unsigned long recursionDepth
);
[edit] Parameters
- thread
- The
nsIThreadon which the event is going to be processed. - mayWait
trueif the method is allowed to block the calling thread. This parameter will befalseduring thread shutdown, for example.- recursionDepth
- The number of calls to
ProcessNextEvent()on the call stack in addition to the current call.
[edit] afterProcessNextEvent()
Called by the nsIThread method processNextEvent() after an event is processed. This method is only called on the target thread.
void afterProcessNextEvent( in nsIThreadInternal thread, in unsigned long recursionDepth )
[edit] Parameters
- thread
- The
nsIThreadon which the event was processed. - recursionDepth
- The number of calls to
ProcessNextEvent()on the call stack in addition to the current call.