|
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/. */ |
|
6 |
|
7 #include "nsISupports.idl" |
|
8 |
|
9 [ptr] native PRThread(PRThread); |
|
10 |
|
11 interface nsIThread; |
|
12 |
|
13 /** |
|
14 * An interface for creating and locating nsIThread instances. |
|
15 */ |
|
16 [scriptable, uuid(1be89eca-e2f7-453b-8d38-c11ba247f6f3)] |
|
17 interface nsIThreadManager : nsISupports |
|
18 { |
|
19 /** |
|
20 * Default number of bytes reserved for a thread's stack, if no stack size |
|
21 * is specified in newThread(). 0 means use platform default. |
|
22 */ |
|
23 const unsigned long DEFAULT_STACK_SIZE = 0; |
|
24 |
|
25 /** |
|
26 * Create a new thread (a global, user PRThread). |
|
27 * |
|
28 * @param creationFlags |
|
29 * Reserved for future use. Pass 0. |
|
30 * @param stackSize |
|
31 * Number of bytes to reserve for the thread's stack. |
|
32 * |
|
33 * @returns |
|
34 * The newly created nsIThread object. |
|
35 */ |
|
36 nsIThread newThread(in unsigned long creationFlags, [optional] in unsigned long stackSize); |
|
37 |
|
38 /** |
|
39 * Get the nsIThread object (if any) corresponding to the given PRThread. |
|
40 * This method returns null if there is no corresponding nsIThread. |
|
41 * |
|
42 * @param prthread |
|
43 * The PRThread of the nsIThread being requested. |
|
44 * |
|
45 * @returns |
|
46 * The nsIThread object corresponding to the given PRThread or null if no |
|
47 * such nsIThread exists. |
|
48 */ |
|
49 [noscript] nsIThread getThreadFromPRThread(in PRThread prthread); |
|
50 |
|
51 /** |
|
52 * Get the main thread. |
|
53 */ |
|
54 readonly attribute nsIThread mainThread; |
|
55 |
|
56 /** |
|
57 * Get the current thread. If the calling thread does not already have a |
|
58 * nsIThread associated with it, then a new nsIThread will be created and |
|
59 * associated with the current PRThread. |
|
60 */ |
|
61 readonly attribute nsIThread currentThread; |
|
62 |
|
63 /** |
|
64 * This attribute is true if the calling thread is the main thread of the |
|
65 * application process. |
|
66 */ |
|
67 readonly attribute boolean isMainThread; |
|
68 }; |