Public Member Functions

nsIThreadObserver Interface Reference

This interface provides the observer with hooks to implement a layered event queue. More...

import "nsIThreadInternal.idl";

Inheritance diagram for nsIThreadObserver:

List of all members.

Public Member Functions

void onDispatchedEvent (in nsIThreadInternal thread)
 This method is called after an event has been dispatched to the thread.
void onProcessNextEvent (in nsIThreadInternal thread, in boolean mayWait, in unsigned long recursionDepth)
 This method is called (from nsIThread::ProcessNextEvent) before an event is processed.
void afterProcessNextEvent (in nsIThreadInternal thread, in unsigned long recursionDepth)
 This method is called (from nsIThread::ProcessNextEvent) after an event is processed.

Detailed Description

This interface provides the observer with hooks to implement a layered event queue.

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

NOTE: The implementation of this interface must be threadsafe.

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

NOTE: Will be split into two interfaces soon: one for onProcessNextEvent and afterProcessNextEvent, then another that inherits the first and adds onDispatchedEvent.


Member Function Documentation

void nsIThreadObserver::afterProcessNextEvent ( in nsIThreadInternal  thread,
in unsigned long  recursionDepth 
)

This method is called (from nsIThread::ProcessNextEvent) after an event is processed.

This method is only called on the target thread.

Parameters:
thread The thread that processed another event.
recursionDepth Indicates the number of calls to ProcessNextEvent on the call stack in addition to the current call.
void nsIThreadObserver::onDispatchedEvent ( in nsIThreadInternal  thread  ) 

This method is called after an event has been dispatched to the thread.

This method may be called from any thread.

Parameters:
thread The thread where the event is being dispatched.
void nsIThreadObserver::onProcessNextEvent ( in nsIThreadInternal  thread,
in boolean  mayWait,
in unsigned long  recursionDepth 
)

This method is called (from nsIThread::ProcessNextEvent) before an event is processed.

This method is only called on the target thread.

Parameters:
thread The thread being asked to process another event.
mayWait Indicates whether or not the method is allowed to block the calling thread. For example, this parameter is false during thread shutdown.
recursionDepth Indicates the number of calls to ProcessNextEvent on the call stack in addition to the current call.

The documentation for this interface was generated from the following file: