XPCOM:nsIThreadManager: Difference between revisions

m
 
(2 intermediate revisions by the same user not shown)
Line 199: Line 199:
   * Create a new thread.
   * Create a new thread.
   *
   *
   * @param name
   * @param result
   *        The name of the thread (must be unique) or the empty string to
   *        The resulting nsIThread object.
  *        create an anonymous thread.
   * @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.
  * @param result
  *        The resulting nsIThread object.
   */
   */
  NS_METHOD NS_NewThread(const nsACString &name, nsIRunnable *event,
  NS_METHOD NS_NewThread(nsIThread **result, nsIRunnable *event);
                        nsIThread **result);
   
   
  /**
  /**
Line 225: Line 221:
   */
   */
  NS_METHOD NS_GetMainThread(nsIThread **result);
  NS_METHOD NS_GetMainThread(nsIThread **result);
 
/**
  * Get a reference to the thread with the given name.
  *
  * @param name
  *        The name of the requested thread.  Must be non-empty.
  * @param result
  *        The resulting nsIThread object.
  */
NS_METHOD NS_GetThread(const nsACString &name, nsIThread **result);
   
   
  /**
  /**
Line 288: Line 274:
   
   
  already_AddRefed<nsIThread> do_GetMainThread();
  already_AddRefed<nsIThread> do_GetMainThread();
&nbsp;
already_AddRefed<nsIThread> do_GetThread(const nsACString &name);


=== nsRunnable ===
=== nsRunnable ===
Line 308: Line 292:
Dispatching <code>MyEvent</code> is then as simple as:
Dispatching <code>MyEvent</code> is then as simple as:


nsCOMPtr<nsIThread> thread = do_GetCurrentThread();
NS_ENSURE_STATE(thread);
&nbsp;
  nsCOMPtr<nsIRunnable> event = new MyEvent();
  nsCOMPtr<nsIRunnable> event = new MyEvent();
  NS_ENSURE_STATE(event);
  rv = NS_DispatchToCurrentThread(event);
  &nbsp;
  NS_ENSURE_SUCCESS(rv, rv);
thread->Dispatch(event, NS_DISPATCH_NORMAL);


== From JS ==
== From JS ==
272

edits