Index: tools/android/forwarder2/thread.cc |
diff --git a/tools/android/forwarder2/thread.cc b/tools/android/forwarder2/thread.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..81e85539f8a24babb690a82a0891a42a38a7b531 |
--- /dev/null |
+++ b/tools/android/forwarder2/thread.cc |
@@ -0,0 +1,32 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "tools/android/forwarder2/thread.h" |
+ |
+#include "base/logging.h" |
+ |
+namespace forwarder { |
+ |
+Thread::Thread() : thread_(static_cast<pthread_t>(-1)) {} |
+ |
+Thread::~Thread() {} |
+ |
+void Thread::Start() { |
+ CHECK_EQ(0, pthread_create(&thread_, NULL, &ThreadCallback, this)); |
+} |
+ |
+void Thread::Join() { |
+ CHECK_NE(static_cast<pthread_t>(-1), thread_); |
+ CHECK_EQ(0, pthread_join(thread_, NULL)); |
+} |
+ |
+// static |
+void* Thread::ThreadCallback(void* arg) { |
+ CHECK(arg); |
+ Thread* obj = reinterpret_cast<Thread*>(arg); |
+ obj->Run(); |
+ return NULL; |
+} |
+ |
+} // namespace forwarder |