|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Utility class for mointoring thread death. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef OSTHREADSUPERVISOR_H |
|
20 #define OSTHREADSUPERVISOR_H |
|
21 |
|
22 #include "javaosheaders.h" |
|
23 |
|
24 namespace java // codescanner::namespace |
|
25 { |
|
26 |
|
27 namespace runtime // codescanner::namespace |
|
28 { |
|
29 |
|
30 /** |
|
31 * This class is responsible for detecting abnormal thread death beloning to |
|
32 * own process. If the abnormal death happens this will terminate the whole |
|
33 * process. This is for Symbian. |
|
34 */ |
|
35 OS_NONSHARABLE_CLASS(OsThreadSupervisor) |
|
36 { |
|
37 public: |
|
38 |
|
39 /** |
|
40 * Constructor of the OsThreadSupervisor. |
|
41 * @param tryThreadDumping Whether to try to do thread dump in panic case. |
|
42 * Might cause another panic. |
|
43 * @throws std::exception on error cases. |
|
44 */ |
|
45 OsThreadSupervisor(bool tryThreadDumping); |
|
46 |
|
47 /** |
|
48 * Destructor of the RuntimeStarterUtils. Will stop the thread monitoring. |
|
49 * The class is not meant to be inherited, so destructor can be non |
|
50 * virtual. |
|
51 */ |
|
52 ~OsThreadSupervisor(); |
|
53 |
|
54 |
|
55 private: // Member variables. |
|
56 |
|
57 TRequestStatus mRequestStatus; |
|
58 RThread mSupervisorThread; |
|
59 bool mDoExit; |
|
60 bool mTryThreadDump; |
|
61 |
|
62 private: // Methods. |
|
63 |
|
64 /** |
|
65 * Starts the undertaker thread in Symbian. |
|
66 * @throw exception on error cases. |
|
67 */ |
|
68 void startUndertakerThread(); |
|
69 |
|
70 /** |
|
71 * The undertaker thread takes out the VM process if any of its threads |
|
72 * panics. This prevents deadlocked zombie VM processes from hanging in |
|
73 * the system if something go wrong. |
|
74 * @param starter A pointer to instance of OsThreadSupervisor. |
|
75 * @return status of the thread execution. |
|
76 */ |
|
77 static int underTakerThreadMain(void* supervisor); |
|
78 |
|
79 /** |
|
80 * No default constructor. |
|
81 */ |
|
82 OsThreadSupervisor(); |
|
83 |
|
84 /* |
|
85 * No copy constructor allowed. |
|
86 */ |
|
87 OsThreadSupervisor(const OsThreadSupervisor&); |
|
88 |
|
89 /* |
|
90 * No Assignment operator allowed. |
|
91 */ |
|
92 OsThreadSupervisor& operator= (const OsThreadSupervisor&); |
|
93 }; |
|
94 |
|
95 } // end namespace runtime |
|
96 } // end namespace java |
|
97 |
|
98 |
|
99 #endif // OSTHREADSUPERVISOR_H |