272
edits
m (→nsIThread) |
m (→nsRunnable) |
||
(6 intermediate revisions by the same user not shown) | |||
Line 6: | Line 6: | ||
interface nsIThreadManager : nsISupports { | interface nsIThreadManager : nsISupports { | ||
/** | /** | ||
* Create a new | * Create a new thread (a global, user PRThread). Currently, flags is | ||
* | * an unused parameter, that must be 0. | ||
*/ | */ | ||
nsIThread newThread(in | nsIThread newThread(in unsigned long flags); | ||
| | ||
/** | /** | ||
Line 73: | Line 65: | ||
[scriptable, uuid(...)] | [scriptable, uuid(...)] | ||
interface nsIThread : nsIEventTarget { | interface nsIThread : nsIEventTarget { | ||
/** | /** | ||
* Returns the PRThread object corresponding to this nsIThread. | * Returns the PRThread object corresponding to this nsIThread. | ||
*/ | */ | ||
[noscript] PRThread | [noscript] readonly attribute PRThread PRThread; | ||
| | ||
/** | /** | ||
Line 100: | Line 86: | ||
/** | /** | ||
* Process the next event. If there are no pending events, then this | * Process the next event. If there are no pending events, then this | ||
* method | * method may wait -- provided mayWait is true -- 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. | ||
* | |||
* @return A boolean value that is "true" if an event was processed. | |||
*/ | */ | ||
boolean processNextEvent(in boolean mayWait); | boolean processNextEvent(in boolean mayWait); | ||
Line 211: | Line 199: | ||
* Create a new thread. | * Create a new thread. | ||
* | * | ||
* @param | * @param result | ||
* The | * The resulting nsIThread object. | ||
* @param event | * @param event | ||
* The initial event to run on this thread. This can be null. | * The initial event to run on this thread. This can be null. | ||
*/ | */ | ||
NS_METHOD NS_NewThread( | NS_METHOD NS_NewThread(nsIThread **result, nsIRunnable *event); | ||
| | ||
/** | /** | ||
Line 237: | Line 221: | ||
*/ | */ | ||
NS_METHOD NS_GetMainThread(nsIThread **result); | NS_METHOD NS_GetMainThread(nsIThread **result); | ||
| | ||
/** | /** | ||
Line 300: | Line 274: | ||
| | ||
already_AddRefed<nsIThread> do_GetMainThread(); | already_AddRefed<nsIThread> do_GetMainThread(); | ||
=== nsRunnable === | === nsRunnable === | ||
Line 320: | Line 292: | ||
Dispatching <code>MyEvent</code> is then as simple as: | Dispatching <code>MyEvent</code> is then as simple as: | ||
nsCOMPtr<nsIRunnable> event = new MyEvent(); | nsCOMPtr<nsIRunnable> event = new MyEvent(); | ||
rv = NS_DispatchToCurrentThread(event); | |||
NS_ENSURE_SUCCESS(rv, rv); | |||
== From JS == | == From JS == |
edits