mozilla

Revision 58798 of The Thread Manager

  • Revision slug: The_Thread_Manager
  • Revision title: The Thread Manager
  • Revision id: 58798
  • Created:
  • Creator: BenjaminSmedberg
  • Is current revision? No
  • Comment 33 words added, 967 words removed

Revision Content

{{ Fx_minversion_header("3") }}

The Thread Manager, introduced in Firefox 3, offers an easy to use mechanism for creating threads and dispatching events to them for processing.

{{ Warning("Only C++ code may use the thread manager and XPCOM thread. Application/Extension JavaScript should consider using a " .. domxref("ChromeWorker") .. " instead.") }}

Interfaces

There are several interfaces that provide threading support:

{{ Interface("nsIThreadManager") }}
The Thread Manager itself lets you create threads.
{{ Interface("nsIThread") }}
The nsIThread interface encapsulates an operating system thread, providing easy cross-platform access to multithreading in your code.
{{ Interface("nsIThreadPool") }}
A thread pool provides a limited set of worker threads. When you dispatch an event to the pool, the pool selects an available worker thread to process the event.
{{ Interface("nsIThreadInternal") }}
A subclass of {{ Interface("nsIThread") }} that is implemented by the XPCOM thread object to add support for observing dispatch activity on a thread.
{{ Interface("nsIThreadObserver") }}
Provides the ability to monitor a thread, to receive notifications when events are dispatched to it and when they're finished being processed.
{{ Interface("nsIThreadEventFilter") }}
This interface is used by the {{ interfacemethod("nsIThreadInternal","pushEventQueue") }} method in {{ Interface("nsIThreadInternal") }} to allow event filtering.
{{ Interface("nsIRunnable") }}
This interface is the base for all events/runnable objects which are dispatched to threads.

Tutorials

{{ languages( { "es": "es/El_administrador_de_hilos", "ja": "ja/The_Thread_Manager" } ) }}

Revision Source

<p>{{ Fx_minversion_header("3") }}</p>
<p>The Thread Manager, introduced in Firefox 3, offers an easy to use mechanism for creating threads and dispatching events to them for processing.</p>
<p>{{ Warning("Only C++ code may use the thread manager and XPCOM thread. Application/Extension JavaScript should consider using a " .. domxref("ChromeWorker") .. " instead.") }}</p>
<h3 id="Interfaces" name="Interfaces">Interfaces</h3>
<p>There are several interfaces that provide threading support:</p>
<dl> <dt>{{ Interface("nsIThreadManager") }}</dt> <dd>The Thread Manager itself lets you create threads.</dd> <dt>{{ Interface("nsIThread") }}</dt> <dd>The <code>nsIThread</code> interface encapsulates an operating system thread, providing easy cross-platform access to multithreading in your code.</dd> <dt>{{ Interface("nsIThreadPool") }}</dt> <dd>A thread pool provides a limited set of worker threads. When you dispatch an event to the pool, the pool selects an available worker thread to process the event.</dd> <dt>{{ Interface("nsIThreadInternal") }}</dt> <dd>A subclass of {{ Interface("nsIThread") }} that is implemented by the XPCOM thread object to add support for observing dispatch activity on a thread.</dd> <dt>{{ Interface("nsIThreadObserver") }}</dt> <dd>Provides the ability to monitor a thread, to receive notifications when events are dispatched to it and when they're finished being processed.</dd> <dt>{{ Interface("nsIThreadEventFilter") }}</dt> <dd>This interface is used by the {{ interfacemethod("nsIThreadInternal","pushEventQueue") }} method in {{ Interface("nsIThreadInternal") }} to allow event filtering.</dd> <dt>{{ Interface("nsIRunnable") }}</dt> <dd>This interface is the base for all events/runnable objects which are dispatched to threads.</dd>
</dl>
<h3 id="Using_the_Thread_Manager" name="Using_the_Thread_Manager">Tutorials</h3>
<ul> <li><a href="/en/Making_Cross-Thread_Calls_Using_Runnables" title="en/Making Cross-Thread Calls Using Runnables">Making Cross-Thread Calls Using Runnables</a></li>
</ul>
<p>{{ languages( { "es": "es/El_administrador_de_hilos", "ja": "ja/The_Thread_Manager" } ) }}</p>
Revert to this revision