XPCOM:nsIEventTargetManager: Difference between revisions
Jump to navigation
Jump to search
m (→Proposal) |
|||
| Line 28: | Line 28: | ||
* | * | ||
* @throws NS_ERROR_INVALID_ARG | * @throws NS_ERROR_INVALID_ARG | ||
* This exception is thrown if target is null, runnable is | * This exception is thrown if target is null, if runnable is | ||
* or if synchronous is set to true and target specifies | * null, or if synchronous is set to true and target specifies | ||
* event target on the current thread. | * an event target on the current thread. | ||
*/ | */ | ||
void postEvent(in nsIEventTarget target, | void postEvent(in nsIEventTarget target, | ||
| Line 43: | Line 43: | ||
* string "current", then the event target of the current thread | * string "current", then the event target of the current thread | ||
* is returned. | * is returned. | ||
* | |||
* @returns null if the named event target is undefined. | |||
*/ | */ | ||
nsIEventTarget getEventTarget(in string name); | nsIEventTarget getEventTarget(in string name); | ||
| Line 57: | Line 59: | ||
* @param target | * @param target | ||
* The event target being set. | * The event target being set. | ||
* | |||
* @throws NS_ERROR_INVALID_ARG | |||
* This exception is thrown if name is null, if target is null, | |||
* or if name is either not unique or invalid. | |||
*/ | */ | ||
void setEventTarget(in string name, in nsIEventTarget target); | void setEventTarget(in string name, in nsIEventTarget target); | ||
}; | }; | ||
Revision as of 21:33, 9 November 2005
Summary
Provide an interface that exposes our event queue system in a freezable and scriptable fashion.
nsIEventTarget abstracts the posting of a PLEvent to a thread event queue. It is currently implemented by nsEventQueue, nsSocketTransportService, and nsIOThreadPool. Most consumers only know how to work with a nsIEventQueue, which is only implemented by the nsEventQueue class.
Proposal
[scriptable, uuid(...)]
interface nsIEventTargetManager : nsISupports
{
/**
* This method dispatches a runnable to the specified event target, which
* may correspond to a different thread.
*
* @param target
* The nsIEventTarget where the runnable will be executed.
* @param runnable
* The nsIRunnable to execute.
* @param synchronous
* If true, then this method will not return until the runnable
* has been executed. If false, then this method will return
* immediately (possibly before the runnable has executed). If
* the event target specifies the current thread, then it is an
* error for this parameter to be true.
*
* @throws NS_ERROR_INVALID_ARG
* This exception is thrown if target is null, if runnable is
* null, or if synchronous is set to true and target specifies
* an event target on the current thread.
*/
void postEvent(in nsIEventTarget target,
in nsIRunnable runnable,
in boolean synchronous);
/** * This method returns an event target by name. * * @param name * The name of the event target requested. If this value is the * string "current", then the event target of the current thread * is returned. * * @returns null if the named event target is undefined. */ nsIEventTarget getEventTarget(in string name);
/** * This method sets the event target for the current thread. If there * was already an event target defined for the current thread, then that * event target is released, and the new event target takes its place. * * @param name * The name of the event target being set. This name must be * unique, and it cannot be the string "current" since that name * is reserved. * @param target * The event target being set. * * @throws NS_ERROR_INVALID_ARG * This exception is thrown if name is null, if target is null, * or if name is either not unique or invalid. */ void setEventTarget(in string name, in nsIEventTarget target); };