OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef TOOLS_ANDROID_FORWARDER2_THREAD_H_ | |
6 #define TOOLS_ANDROID_FORWARDER2_THREAD_H_ | |
7 | |
8 #include <pthread.h> | |
9 | |
10 namespace forwarder2 { | |
11 | |
12 // Helper abstract class to create a new thread and curry the | |
13 // call to the Run() method in an object from the new thread. | |
14 class Thread { | |
15 public: | |
16 Thread(); | |
17 virtual ~Thread(); | |
18 | |
19 // Start thread calling Run(). | |
20 void Start(); | |
21 void Detach(); | |
22 virtual void Join(); | |
23 | |
24 protected: | |
25 virtual void Run() = 0; | |
26 | |
27 private: | |
28 static void* ThreadCallback(void* arg); | |
29 | |
30 pthread_t thread_; | |
31 }; | |
32 | |
33 } // namespace forwarder | |
34 | |
35 #endif // TOOLS_ANDROID_FORWARDER2_THREAD_H_ | |
OLD | NEW |