Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim:set ts=2 sw=2 sts=2 et cindent: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #include "nsIEventTarget.idl" |
michael@0 | 8 | |
michael@0 | 9 | [scriptable, uuid(ef194cab-3f86-4b61-b132-e5e96a79e5d1)] |
michael@0 | 10 | interface nsIThreadPoolListener : nsISupports |
michael@0 | 11 | { |
michael@0 | 12 | /** |
michael@0 | 13 | * Called when a new thread is created by the thread pool. The notification |
michael@0 | 14 | * happens on the newly-created thread. |
michael@0 | 15 | */ |
michael@0 | 16 | void onThreadCreated(); |
michael@0 | 17 | |
michael@0 | 18 | /** |
michael@0 | 19 | * Called when a thread is about to be destroyed by the thread pool. The |
michael@0 | 20 | * notification happens on the thread that is about to be destroyed. |
michael@0 | 21 | */ |
michael@0 | 22 | void onThreadShuttingDown(); |
michael@0 | 23 | }; |
michael@0 | 24 | |
michael@0 | 25 | /** |
michael@0 | 26 | * An interface to a thread pool. A thread pool creates a limited number of |
michael@0 | 27 | * anonymous (unnamed) worker threads. An event dispatched to the thread pool |
michael@0 | 28 | * will be run on the next available worker thread. |
michael@0 | 29 | */ |
michael@0 | 30 | [scriptable, uuid(53675068-cb3a-40e5-a026-1be5a97c9b23)] |
michael@0 | 31 | interface nsIThreadPool : nsIEventTarget |
michael@0 | 32 | { |
michael@0 | 33 | /** |
michael@0 | 34 | * Shutdown the thread pool. This method may not be executed from any thread |
michael@0 | 35 | * in the thread pool. Instead, it is meant to be executed from another |
michael@0 | 36 | * thread (usually the thread that created this thread pool). When this |
michael@0 | 37 | * function returns, the thread pool and all of its threads will be shutdown, |
michael@0 | 38 | * and it will no longer be possible to dispatch tasks to the thread pool. |
michael@0 | 39 | * |
michael@0 | 40 | * As a side effect, events on the current thread will be processed. |
michael@0 | 41 | */ |
michael@0 | 42 | void shutdown(); |
michael@0 | 43 | |
michael@0 | 44 | /** |
michael@0 | 45 | * Get/set the maximum number of threads allowed at one time in this pool. |
michael@0 | 46 | */ |
michael@0 | 47 | attribute unsigned long threadLimit; |
michael@0 | 48 | |
michael@0 | 49 | /** |
michael@0 | 50 | * Get/set the maximum number of idle threads kept alive. |
michael@0 | 51 | */ |
michael@0 | 52 | attribute unsigned long idleThreadLimit; |
michael@0 | 53 | |
michael@0 | 54 | /** |
michael@0 | 55 | * Get/set the amount of time in milliseconds before an idle thread is |
michael@0 | 56 | * destroyed. |
michael@0 | 57 | */ |
michael@0 | 58 | attribute unsigned long idleThreadTimeout; |
michael@0 | 59 | |
michael@0 | 60 | /** |
michael@0 | 61 | * Get/set the number of bytes reserved for the stack of all threads in |
michael@0 | 62 | * the pool. By default this is nsIThreadManager::DEFAULT_STACK_SIZE. |
michael@0 | 63 | */ |
michael@0 | 64 | attribute unsigned long threadStackSize; |
michael@0 | 65 | |
michael@0 | 66 | /** |
michael@0 | 67 | * An optional listener that will be notified when a thread is created or |
michael@0 | 68 | * destroyed in the course of the thread pool's operation. |
michael@0 | 69 | * |
michael@0 | 70 | * A listener will only receive notifications about threads created after the |
michael@0 | 71 | * listener is set so it is recommended that the consumer set the listener |
michael@0 | 72 | * before dispatching the first event. A listener that receives an |
michael@0 | 73 | * onThreadCreated() notification is guaranteed to always receive the |
michael@0 | 74 | * corresponding onThreadShuttingDown() notification. |
michael@0 | 75 | * |
michael@0 | 76 | * The thread pool takes ownership of the listener and releases it when the |
michael@0 | 77 | * shutdown() method is called. Threads created after the listener is set will |
michael@0 | 78 | * also take ownership of the listener so that the listener will be kept alive |
michael@0 | 79 | * long enough to receive the guaranteed onThreadShuttingDown() notification. |
michael@0 | 80 | */ |
michael@0 | 81 | attribute nsIThreadPoolListener listener; |
michael@0 | 82 | |
michael@0 | 83 | /** |
michael@0 | 84 | * Set the label for threads in the pool. All threads will be named |
michael@0 | 85 | * "<aName> #<n>", where <n> is a serial number. |
michael@0 | 86 | */ |
michael@0 | 87 | void setName(in ACString aName); |
michael@0 | 88 | }; |