Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Side by Side Diff: tools/android/forwarder2/thread.cc

Issue 19478003: Remove Thread wrapper class in forwarder2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Marcus' comments Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/android/forwarder2/thread.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 forwarder2 {
10
11 Thread::Thread() : thread_(static_cast<pthread_t>(-1)) {}
12
13 Thread::~Thread() {}
14
15 void Thread::Start() {
16 int ret = pthread_create(&thread_, NULL, &ThreadCallback, this);
17 CHECK_EQ(0, ret);
18 }
19
20 void Thread::Detach() {
21 CHECK_NE(static_cast<pthread_t>(-1), thread_);
22 int ret = pthread_detach(thread_);
23 CHECK_EQ(0, ret);
24 }
25
26 void Thread::Join() {
27 CHECK_NE(static_cast<pthread_t>(-1), thread_);
28 int ret = pthread_join(thread_, NULL);
29 CHECK_EQ(0, ret);
30 }
31
32 // static
33 void* Thread::ThreadCallback(void* arg) {
34 CHECK(arg);
35 Thread* obj = reinterpret_cast<Thread*>(arg);
36 obj->Run();
37 return NULL;
38 }
39
40 } // namespace forwarder
OLDNEW
« no previous file with comments | « tools/android/forwarder2/thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698