Bug 1867190 - Initialise the PHC allocate delay later r=glandium
[gecko.git] / xpcom / threads / nsIThreadPool.idl
blob48b4a465d85886ab14aec74430d62252329efc08
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "nsIEventTarget.idl"
8 #include "nsIThread.idl"
10 [uuid(ef194cab-3f86-4b61-b132-e5e96a79e5d1)]
11 interface nsIThreadPoolListener : nsISupports
13 /**
14 * Called when a new thread is created by the thread pool. The notification
15 * happens on the newly-created thread.
17 void onThreadCreated();
19 /**
20 * Called when a thread is about to be destroyed by the thread pool. The
21 * notification happens on the thread that is about to be destroyed.
23 void onThreadShuttingDown();
26 /**
27 * An interface to a thread pool. A thread pool creates a limited number of
28 * anonymous (unnamed) worker threads. An event dispatched to the thread pool
29 * will be run on the next available worker thread.
31 [rust_sync, uuid(76ce99c9-8e43-489a-9789-f27cc4424965)]
32 interface nsIThreadPool : nsIEventTarget
34 /**
35 * Set the entire pool's QoS priority. If the priority has not changed, do nothing.
36 * Existing threads will update their QoS priority the next time they become
37 * active, and newly created threads will set this QoS priority upon creation.
39 [noscript] void setQoSForThreads(in nsIThread_QoSPriority aPriority);
41 /**
42 * Shutdown the thread pool. This method may not be executed from any thread
43 * in the thread pool. Instead, it is meant to be executed from another
44 * thread (usually the thread that created this thread pool). When this
45 * function returns, the thread pool and all of its threads will be shutdown,
46 * and it will no longer be possible to dispatch tasks to the thread pool.
48 * As a side effect, events on the current thread will be processed.
50 void shutdown();
52 /**
53 * Shutdown the thread pool, but only wait for aTimeoutMs. After the timeout
54 * expires, any threads that have not shutdown yet are leaked and will not
55 * block shutdown.
57 * This method should only be used at during shutdown to cleanup threads that
58 * made blocking calls to code outside our control, and can't be safely
59 * terminated. We choose to leak them intentionally to avoid a shutdown hang.
61 [noscript] void shutdownWithTimeout(in long aTimeoutMs);
63 /**
64 * Get/set the maximum number of threads allowed at one time in this pool.
66 attribute unsigned long threadLimit;
68 /**
69 * Get/set the maximum number of idle threads kept alive.
71 attribute unsigned long idleThreadLimit;
73 /**
74 * Get/set the amount of time in milliseconds before an idle thread is
75 * destroyed.
77 attribute unsigned long idleThreadTimeout;
79 /**
80 * If set to true the idle timeout will be calculated as idleThreadTimeout
81 * divideded by the number of idle threads at the moment. This may help
82 * save memory allocations but still keep reasonable amount of idle threads.
83 * Default is false, use |idleThreadTimeout| for all threads.
85 attribute boolean idleThreadTimeoutRegressive;
87 /**
88 * Get/set the number of bytes reserved for the stack of all threads in
89 * the pool. By default this is nsIThreadManager::DEFAULT_STACK_SIZE.
91 attribute unsigned long threadStackSize;
93 /**
94 * An optional listener that will be notified when a thread is created or
95 * destroyed in the course of the thread pool's operation.
97 * A listener will only receive notifications about threads created after the
98 * listener is set so it is recommended that the consumer set the listener
99 * before dispatching the first event. A listener that receives an
100 * onThreadCreated() notification is guaranteed to always receive the
101 * corresponding onThreadShuttingDown() notification.
103 * The thread pool takes ownership of the listener and releases it when the
104 * shutdown() method is called. Threads created after the listener is set will
105 * also take ownership of the listener so that the listener will be kept alive
106 * long enough to receive the guaranteed onThreadShuttingDown() notification.
108 attribute nsIThreadPoolListener listener;
111 * Set the label for threads in the pool. All threads will be named
112 * "<aName> #<n>", where <n> is a serial number.
114 void setName(in ACString aName);