Interface nsIThreadInternalType

The XPCOM thread object implements this interface, which allows a consumer to observe dispatch activity on the thread.

Hierarchy

Properties

CanInvokeJS: boolean

Returns

Whether or not this thread may call into JS. Used in the profiler to avoid some unnecessary locking.

PRThread: PRThread

Returns

The NSPR thread object corresponding to this nsIThread.

lastLongNonIdleTaskEnd: TimeStamp
lastLongTaskEnd: TimeStamp

This is set to the end of the last 50+ms event that was executed on this thread (for MainThread only). Otherwise returns a null TimeStamp.

observer: nsIThreadObserver

Get/set the current thread observer (may be null). This attribute may be read from any thread, but must only be set on the thread corresponding to this thread object. The observer will be released on the thread corresponding to this thread object after all other events have been processed during a call to Shutdown.

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

  • Add an observer that will only receive onProcessNextEvent, beforeProcessNextEvent. and afterProcessNextEvent callbacks. Always called on the target thread, and the implementation does not have to be threadsafe. Order of callbacks is not guaranteed (i.e. afterProcessNextEvent may be called first depending on whether or not the observer is added in a nested loop). Holds a strong ref.

    Parameters

    • observer: nsIThreadObserver

    Returns void

  • Shutdown the thread asynchronously. This method immediately prevents further dispatch of events to the thread, and it causes any pending events to run to completion before this thread joins with the current thread.

    UNLIKE shutdown() this does not process events on the current thread. Instead it merely ensures that the current thread continues running until this thread has shut down.

    This method MAY NOT be executed from the thread itself. Instead, it is meant to be executed from another thread (usually the thread that created this thread or the main application thread). When this function returns, the thread will continue running until it exhausts its event queue.

    Throws

    NS_ERROR_UNEXPECTED Indicates that this method was erroneously called when this thread was the current thread, that this thread was not created with a call to nsIThreadManager::NewNamedThread, or that this method was called more than once on the thread object.

    Returns void

  • Like asyncShutdown, but also returns a nsIThreadShutdown instance to allow observing and controlling the thread's async shutdown progress.

    Returns nsIThreadShutdown

  • Dispatch an event to this event target, but do not run it before delay milliseconds have passed. This function may be called from any thread.

    Throws

    NS_ERROR_INVALID_ARG Indicates that event is null.

    Throws

    NS_ERROR_UNEXPECTED Indicates that the thread is shutting down and has finished processing events, so this event would never run and has not been dispatched, or that delay is zero.

    Parameters

    • event: alreadyAddRefed_nsIRunnable

      The alreadyAddrefed<> event to dispatch.

    • delay: number

      The delay (in ms) before running the event. If event does not rise to the top of the event queue before the delay has passed, it will be set aside to execute once the delay has passed. Otherwise, it will be executed immediately.

    Returns void

  • Version of Dispatch to expose to JS, which doesn't require an alreadyAddRefed<> (it will be converted to that internally)

    Throws

    NS_ERROR_INVALID_ARG Indicates that event is null.

    Throws

    NS_ERROR_UNEXPECTED Indicates that the thread is shutting down and has finished processing events, so this event would never run and has not been dispatched.

    Parameters

    • event: nsIRunnable

      The (raw) event to dispatch.

    • flags: number

      The flags modifying event dispatch. The flags are described in detail below.

    Returns void

  • Dispatch an event to this event target. This function may be called from any thread, and it may be called re-entrantly.

    Throws

    NS_ERROR_INVALID_ARG Indicates that event is null.

    Throws

    NS_ERROR_UNEXPECTED Indicates that the thread is shutting down and has finished processing events, so this event would never run and has not been dispatched.

    Parameters

    • event: alreadyAddRefed_nsIRunnable

      The alreadyAddRefed<> event to dispatch. NOTE that the event will be leaked if it fails to dispatch.

    • flags: number

      The flags modifying event dispatch. The flags are described in detail below.

    Returns void

  • Dispatch an event to a specified queue for the thread. This function may be called from any thread, and it may be called re-entrantly. Most users should use the NS_Dispatch*() functions in nsThreadUtils instead of calling this directly.

    Throws

    NS_ERROR_INVALID_ARG Indicates that event is null.

    Throws

    NS_ERROR_UNEXPECTED Indicates that the thread is shutting down and has finished processing events, so this event would never run and has not been dispatched.

    Parameters

    • event: alreadyAddRefed_nsIRunnable

      The alreadyAddRefed<> event to dispatch. NOTE that the event will be leaked if it fails to dispatch.

    • queue: EventQueuePriority

      Which event priority queue this should be added to

    Returns void

  • Get information on the timing of the currently-running event.

    Parameters

    • delay: TimeDuration

      The amount of time the current running event in the specified queue waited to run. Will return TimeDuration() if the queue is empty or has not run any new events since event delay monitoring started. NOTE: delay will be TimeDuration() if this thread uses a PrioritizedEventQueue (i.e. MainThread) and the event priority is below Input.

    • start: TimeStamp

      The time the currently running event began to run, or TimeStamp() if no event is running.

    Returns void

  • This method may be called to determine if there are any events ready to be processed. It may only be called when this thread is the current thread.

    Because events may be added to this thread by another thread, a "false" result does not mean that this thread has no pending events. It only means that there were no pending events when this method was called.

    Returns

    A boolean value that if "true" indicates that this thread has one or more pending events.

    Throws

    NS_ERROR_UNEXPECTED Indicates that this method was erroneously called when this thread was not the current thread.

    Returns boolean

  • Process the next event. If there are no pending events, then this method may wait -- depending on the value of the mayWait parameter -- until an event is dispatched to this thread. This method is re-entrant but may only be called if this thread is the current thread.

    Returns

    A boolean value that if "true" indicates that an event was processed.

    Throws

    NS_ERROR_UNEXPECTED Indicates that this method was erroneously called when this thread was not the current thread.

    Parameters

    • mayWait: boolean

      A boolean parameter that if "true" indicates that the method may block the calling thread to wait for a pending event.

    Returns boolean

  • Register an task to be run on this event target when it begins shutting down. Shutdown tasks may be run in any order, and this function may be called from any thread.

    The event target may or may not continue accepting events during or after the shutdown task. The precise behaviour here depends on the event target.

    Throws

    NS_ERROR_INVALID_ARG Indicates that task is null.

    Throws

    NS_ERROR_NOT_IMPLEMENTED Indicates that this event target doesn't support shutdown tasks.

    Throws

    NS_ERROR_UNEXPECTED Indicates that the thread is already shutting down, and no longer accepting events.

    Parameters

    • task: nsITargetShutdownTask

      The task to be registered to the target thread. NOTE that unlike dispatch, this will not leak the task if it fails.

    Returns void

  • Remove an observer added via the addObserver call. Once removed the observer will never be called again by the thread.

    Parameters

    • observer: nsIThreadObserver

    Returns void

  • Set information on the timing of the currently-running event. Overrides the values returned by getRunningEventDelay

    Parameters

    • delay: TimeDuration

      Delay the running event spent in queues, or TimeDuration() if there's no running event.

    • start: TimeStamp

      The time the currently running event began to run, or TimeStamp() if no event is running.

    Returns void

  • Set the QoS priority of threads where this may be available. Currently restricted to MacOS. Must be on the thread to call this method.

    Parameters

    • aPriority: nsIThread_QoSPriority

      The specified priority we will adjust to. Can be low (background) or normal (default / user-interactive)

    Returns void

  • Shutdown the thread. This method prevents further dispatch of events to the thread, and it causes any pending events to run to completion before the thread joins (see PR_JoinThread) with the current thread. During this method call, events for the current thread may be processed.

    This method MAY NOT be executed from the thread itself. Instead, it is meant to be executed from another thread (usually the thread that created this thread or the main application thread). When this function returns, the thread will be shutdown, and it will no longer be possible to dispatch events to the thread.

    Throws

    NS_ERROR_UNEXPECTED Indicates that this method was erroneously called when this thread was the current thread, that this thread was not created with a call to nsIThreadManager::NewThread, or if this method was called more than once on the thread object.

    Returns void

  • Unregisters an task previously registered with registerShutdownTask. This function may be called from any thread.

    Throws

    NS_ERROR_INVALID_ARG Indicates that task is null.

    Throws

    NS_ERROR_NOT_IMPLEMENTED Indicates that this event target doesn't support shutdown tasks.

    Throws

    NS_ERROR_UNEXPECTED Indicates that the thread is already shutting down, and no longer accepting events, or that the shutdown task cannot be found.

    Parameters

    • task: nsITargetShutdownTask

      The task previously registered with registerShutdownTask

    Returns void

Generated using TypeDoc