Interface nsIThreadObserverType

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() { NativeQueue.signal(); } onProcessNextEvent(thread, mayWait) { 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.

Hierarchy

Methods

  • Increases the reference count for this interface. The associated instance will not be deleted unless the reference count is returned to zero.

    Returns

    The resulting reference count.

    Returns number

  • Parameters

    • aIID: object
    • Optional aInstancePtr: object

    Returns any

  • A run time mechanism for interface discovery.

    Returns

    NS_OK if the interface is supported by the associated instance, NS_NOINTERFACE if it is not.

    aInstancePtr must not be null.

    Parameters

    • aIID: object

      [in] A requested interface IID

    • aInstancePtr: object

      [out] A pointer to an interface pointer to receive the result.

    Returns void

  • Decreases the reference count for this interface. Generally, if the reference count returns to zero, the associated instance is deleted.

    Returns

    The resulting reference count.

    Returns number

  • This method is called (from nsIThread::ProcessNextEvent) after an event is processed. It does not guarantee that an event was actually processed (depends on the value of |eventWasProcessed|. This method is only called on the target thread. DO NOT EVER RUN SCRIPT FROM THIS CALLBACK!!!

    Parameters

    • thread: nsIThreadInternal

      The thread that processed another event.

    • eventWasProcessed: bool

      Indicates whether an event was actually processed. May be false if the |mayWait| flag was false when calling nsIThread::ProcessNextEvent().

    Returns void

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

    Returns void

  • This method is called when nsIThread::ProcessNextEvent is called. It does not guarantee that an event is actually going to be processed. This method is only called on the target thread.

    Parameters

    • thread: nsIThreadInternal

      The thread being asked to process another event.

    • mayWait: boolean

      Indicates whether or not the method is allowed to block the calling thread. For example, this parameter is false during thread shutdown.

    Returns void

Generated using TypeDoc