The nsIThreadObserver
interface may be implemented to let an observer implement a layered event queue.
The implementation of this interface must be thread safe.
Inherits from: nsISupports
void afterProcessNextEvent(in nsIThreadInternal thread, in unsigned long recursionDepth); |
void onDispatchedEvent(in nsIThreadInternal thread); |
void onProcessNextEvent(in nsIThreadInternal thread, in boolean mayWait, in unsigned long recursionDepth); |
Called by the nsIThread
method nsIThread.ProcessNextEvent()
after an event is processed. This method is only called on the target thread.
void afterProcessNextEvent( in nsIThreadInternal thread, in unsigned long recursionDepth );
thread
nsIThread
on which the event was processed.recursionDepth
nsIThread.ProcessNextEvent()
on the call stack in addition to the current call.Called after an event has been dispatched to the thread. This method may be called from any thread.
void onDispatchedEvent( in nsIThreadInternal thread );
thread
nsIThread
on which the event was dispatched.Called by the nsIThread
method nsIThread.ProcessNextEvent()
before an event is processed. This method is only called on the target thread.
It is valid to change the thread\'s observer during a call to this method.
void onProcessNextEvent( in nsIThreadInternal thread, in boolean mayWait, in unsigned long recursionDepth );
thread
nsIThread
on which the event is going to be processed.mayWait
true
if the method is allowed to block the calling thread. This parameter will be false
during thread shutdown.recursionDepth
nsIThread.ProcessNextEvent()
on the call stack in addition to the current call.It is 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(); } } };