nsIThreadPool 编辑

xpcom/threads/nsIThreadPool.idlScriptable The nsIThreadPool interface provides support for thread pools. 1.0 66 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

AttributeTypeDescription
idleThreadLimitunsigned longGet/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.
idleThreadTimeoutunsigned longGet/set the amount of time in milliseconds that a thread must be idle before it becomes eligible to be destroyed.
listenernsIThreadPoolListener

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.
threadLimitunsigned longThe 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.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:124 次

字数:5278

最后编辑:6 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文