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 #include "tools/android/forwarder2/thread.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 |
| 9 namespace forwarder { |
| 10 |
| 11 Thread::Thread() : thread_(static_cast<pthread_t>(-1)) {} |
| 12 |
| 13 Thread::~Thread() {} |
| 14 |
| 15 void Thread::Start() { |
| 16 CHECK_EQ(0, pthread_create(&thread_, NULL, &ThreadCallback, this)); |
| 17 } |
| 18 |
| 19 void Thread::Join() { |
| 20 CHECK_NE(static_cast<pthread_t>(-1), thread_); |
| 21 CHECK_EQ(0, pthread_join(thread_, NULL)); |
| 22 } |
| 23 |
| 24 // static |
| 25 void* Thread::ThreadCallback(void* arg) { |
| 26 CHECK(arg); |
| 27 Thread* obj = reinterpret_cast<Thread*>(arg); |
| 28 obj->Run(); |
| 29 return NULL; |
| 30 } |
| 31 |
| 32 } // namespace forwarder |
OLD | NEW |