Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

nsIThreadObserver

The nsIThreadObserver interface may be implemented to let an observer implement a layered event queue.

Warning: The implementation of this interface must be thread safe.

Please add a summary to this article.
  Last changed in Gecko 1.9 (Firefox 3)

Inherits from: nsISupports

Method overview

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);

Methods

afterProcessNextEvent()

Called by the nsIThread method nsIThread.ProcessNextEvent() after an event is processed. This method is only called on the target thread.

Note: It is valid to change the thread's observer during a call to this method.

void afterProcessNextEvent(
  in nsIThreadInternal thread,
  in unsigned long recursionDepth
);
Parameters
thread
The nsIThread on which the event was processed.
recursionDepth
The number of calls to nsIThread.ProcessNextEvent() on the call stack in addition to the current call.

onDispatchedEvent()

Called after an event has been dispatched to the thread. This method may be called from any thread.

Note: It is valid to change the thread's observer during a call to this method.

void onDispatchedEvent(
  in nsIThreadInternal thread
);
Parameters
thread
The nsIThread on which the event was dispatched.

onProcessNextEvent()

Called by the nsIThread method nsIThread.ProcessNextEvent() before an event is processed. This method is only called on the target thread.

Note: 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
);
Parameters
thread
The 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
The number of calls to nsIThread.ProcessNextEvent() on the call stack in addition to the current call.

Example

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();
    }
  }
};

See also

Document Tags and Contributors

 Contributors to this page: Sheppy, trevorh, Kohei
 Last updated by: Sheppy,