nsIThreadPool

The nsIThreadPool interface provides support for thread pools.
1.0
28
Introduced
Gecko 1.9
Inherits from: nsIEventTarget Last changed in Gecko 1.9.1 (Firefox 3.5 / Thunderbird 3.0 / SeaMonkey 2.0)

A thread pool provides a convenient way to process events off the main thread. When you send events to the thread pool, the pool creates a new thread to process the event, up to the number of threads specified by the threadLimit attribute.

Method overview

void shutdown();

Attributes

Attribute Type Description
idleThreadLimit unsigned long Get/set the maximum number of idle threads that are kept alive. Once there are more than this many idle worker threads, the idle threads start getting destroyed.
idleThreadTimeout unsigned long Get/set the amount of time in milliseconds that a thread must be idle before it becomes eligible to be destroyed.
listener nsIThreadPoolListener

An optional listener that will be notified when a thread is created or destroyed in the course of the thread pool's operation.

A listener will only receive notifications about threads created after the listener is set so it is recommended that the consumer set the listener before dispatching the first event. A listener that receives an nsIThreadPoolListener.onThreadCreated() notification is guaranteed to always receive the corresponding nsIThreadPoolListener.onThreadShuttingDown() notification.

The thread pool takes ownership of the listener and releases it when the shutdown() method is called. Threads created after the listener is set will also take ownership of the listener so that the listener will be kept alive long enough to receive the guaranteed nsIThreadPoolListener.onThreadShuttingDown() notification.
threadLimit unsigned long The maximum number of threads allowed at once in the pool; you may change this value by altering this attribute.

Methods

shutdown()

Shuts down the thread pool.

Warning: You must not call this method from any thread within the thread pool. Instead, you should call it from another thread (typically the one that created the thread pool).

When this method returns, the thread pool and all its threads will have been shut down, and it is no longer be possible to dispatch events to the thread pool.

void shutdown();
Parameters

None.

See also

Document Tags and Contributors

 Contributors to this page: Sheppy, trevorh, Jürgen Jeka, Kohei
 Last updated by: Sheppy,