Interface nsISerialEventTargetType

A serial event target is an event dispatching interface like nsIEventTarget. Runnables dispatched to an nsISerialEventTarget are required to execute serially. That is, two different runnables dispatched to the target should never be allowed to execute simultaneously. One exception to this rule is nested event loops. If a runnable spins a nested event loop, causing another runnable dispatched to the target to run, the target may still be considered "serial".

Examples:

  • nsIThread is a serial event target.
  • Thread pools are not serial event targets.
  • However, one can "convert" a thread pool into an nsISerialEventTarget by putting a TaskQueue in front of it.

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

  • 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

  • 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

  • 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