OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Crashpad Authors. All rights reserved. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 | |
15 #ifndef CRASHPAD_UTIL_TEST_THREAD_H_ | |
16 #define CRASHPAD_UTIL_TEST_THREAD_H_ | |
17 | |
18 #include "base/basictypes.h" | |
19 #include "build/build_config.h" | |
20 | |
21 #if defined(OS_POSIX) | |
22 #include <pthread.h> | |
23 #elif defined(OS_WIN) | |
24 #include <windows.h> | |
25 #endif // OS_POSIX | |
26 | |
27 namespace crashpad { | |
28 namespace test { | |
29 | |
30 //! \brief Basic thread abstraction for testing. Users should derive from this | |
31 //! class and implement Main(). | |
32 class Thread { | |
33 public: | |
34 Thread(); | |
35 virtual ~Thread(); | |
36 | |
37 //! \brief Create a platform thread, and run Main() on that thread. Must be | |
38 //! paired with a call to Join(). | |
39 void Start(); | |
40 | |
41 //! \brief Block until Main() exits. This may be called from any thread. Must | |
42 //! paired with a call to Start(). | |
43 void Join(); | |
44 | |
45 protected: | |
Mark Mentovai
2015/03/20 22:11:37
private’s probably fine.
scottmg
2015/03/20 22:32:53
Done.
| |
46 //! \brief The entry point to be overridden to implement the test-specific | |
47 //! functionality. | |
48 virtual void Main() = 0; | |
Mark Mentovai
2015/03/20 22:11:37
ThreadMain()?
scottmg
2015/03/20 22:32:53
Done.
| |
49 | |
50 private: | |
51 static | |
52 #if defined(OS_POSIX) | |
53 void* | |
54 #elif defined(OS_WIN) | |
55 DWORD WINAPI | |
56 #endif // OS_POSIX | |
57 ThreadEntryThunk(void* argument); | |
58 | |
59 #if defined(OS_POSIX) | |
60 pthread_t platform_thread_; | |
61 #elif defined(OS_WIN) | |
62 HANDLE platform_thread_; | |
63 #endif | |
64 | |
65 DISALLOW_COPY_AND_ASSIGN(Thread); | |
66 }; | |
67 | |
68 } // namespace test | |
69 } // namespace crashpad | |
70 | |
71 #endif // CRASHPAD_UTIL_TEST_THREAD_H_ | |
OLD | NEW |