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 forwarder { |
| 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 virtual void Join(); |
| 22 |
| 23 protected: |
| 24 virtual void Run() = 0; |
| 25 |
| 26 private: |
| 27 static void* ThreadCallback(void* arg); |
| 28 |
| 29 pthread_t thread_; |
| 30 }; |
| 31 |
| 32 } // namespace forwarder |
| 33 |
| 34 #endif // TOOLS_ANDROID_FORWARDER2_THREAD_H_ |
OLD | NEW |