/work/obj-fuzz/dist/include/MainThreadUtils.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
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 | | #ifndef MainThreadUtils_h_ |
8 | | #define MainThreadUtils_h_ |
9 | | |
10 | | #include "nscore.h" |
11 | | |
12 | | class nsIThread; |
13 | | |
14 | | /** |
15 | | * Get a reference to the main thread. |
16 | | * |
17 | | * @param aResult |
18 | | * The resulting nsIThread object. |
19 | | */ |
20 | | extern nsresult NS_GetMainThread(nsIThread** aResult); |
21 | | |
22 | | #ifdef MOZILLA_INTERNAL_API |
23 | | // Fast access to the current thread. Do not release the returned pointer! If |
24 | | // you want to use this pointer from some other thread, then you will need to |
25 | | // AddRef it. Otherwise, you should only consider this pointer valid from code |
26 | | // running on the current thread. |
27 | | extern nsIThread* NS_GetCurrentThread(); |
28 | | #endif |
29 | | |
30 | | #ifdef MOZILLA_INTERNAL_API |
31 | | bool NS_IsMainThreadTLSInitialized(); |
32 | | bool NS_IsMainThread(); |
33 | | |
34 | | namespace mozilla { |
35 | | |
36 | | #ifdef DEBUG |
37 | | void |
38 | | AssertIsOnMainThread(); |
39 | | #else |
40 | | inline void |
41 | | AssertIsOnMainThread() |
42 | 0 | { } |
43 | | #endif |
44 | | |
45 | | } // mozilla namespace |
46 | | |
47 | | #endif |
48 | | |
49 | | #endif // MainThreadUtils_h_ |