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

Side by Side Diff: webrtc/system_wrappers/source/thread_posix.cc

Issue 1467243003: Remove ThreadWrapper::GetThreadId. The method just calls rtc::CurrentThreadId(), which also has a m… (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/system_wrappers/source/thread_posix.h" 11 #include "webrtc/system_wrappers/source/thread_posix.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 14
15 #include <errno.h> 15 #include <errno.h>
16 #include <unistd.h> 16 #include <unistd.h>
17 #ifdef WEBRTC_LINUX 17 #ifdef WEBRTC_LINUX
18 #include <linux/unistd.h> 18 #include <linux/unistd.h>
19 #include <sched.h> 19 #include <sched.h>
20 #include <sys/types.h> 20 #include <sys/types.h>
21 #endif 21 #endif
22 22
23 #include "webrtc/base/checks.h" 23 #include "webrtc/base/checks.h"
24 #include "webrtc/base/platform_thread.h"
25 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" 24 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
26 #include "webrtc/system_wrappers/include/event_wrapper.h" 25 #include "webrtc/system_wrappers/include/event_wrapper.h"
27 #include "webrtc/system_wrappers/include/sleep.h" 26 #include "webrtc/system_wrappers/include/sleep.h"
28 #include "webrtc/system_wrappers/include/trace.h" 27 #include "webrtc/system_wrappers/include/trace.h"
29 28
30 namespace webrtc { 29 namespace webrtc {
31 namespace { 30 namespace {
32 struct ThreadAttributes { 31 struct ThreadAttributes {
33 ThreadAttributes() { pthread_attr_init(&attr); } 32 ThreadAttributes() { pthread_attr_init(&attr); }
34 ~ThreadAttributes() { pthread_attr_destroy(&attr); } 33 ~ThreadAttributes() { pthread_attr_destroy(&attr); }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 ThreadPosix::ThreadPosix(ThreadRunFunction func, void* obj, 69 ThreadPosix::ThreadPosix(ThreadRunFunction func, void* obj,
71 const char* thread_name) 70 const char* thread_name)
72 : run_function_(func), 71 : run_function_(func),
73 obj_(obj), 72 obj_(obj),
74 stop_event_(false, false), 73 stop_event_(false, false),
75 name_(thread_name ? thread_name : "webrtc"), 74 name_(thread_name ? thread_name : "webrtc"),
76 thread_(0) { 75 thread_(0) {
77 RTC_DCHECK(name_.length() < 64); 76 RTC_DCHECK(name_.length() < 64);
78 } 77 }
79 78
80 uint32_t ThreadWrapper::GetThreadId() {
81 return rtc::CurrentThreadId();
82 }
83
84 ThreadPosix::~ThreadPosix() { 79 ThreadPosix::~ThreadPosix() {
85 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 80 RTC_DCHECK(thread_checker_.CalledOnValidThread());
86 } 81 }
87 82
88 // TODO(pbos): Make Start void, calling code really doesn't support failures 83 // TODO(pbos): Make Start void, calling code really doesn't support failures
89 // here. 84 // here.
90 bool ThreadPosix::Start() { 85 bool ThreadPosix::Start() {
91 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 86 RTC_DCHECK(thread_checker_.CalledOnValidThread());
92 RTC_DCHECK(!thread_) << "Thread already started?"; 87 RTC_DCHECK(!thread_) << "Thread already started?";
93 88
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 // It's a requirement that for successful thread creation that the run 152 // It's a requirement that for successful thread creation that the run
158 // function be called at least once (see RunFunctionIsCalled unit test), 153 // function be called at least once (see RunFunctionIsCalled unit test),
159 // so to fullfill that requirement, we use a |do| loop and not |while|. 154 // so to fullfill that requirement, we use a |do| loop and not |while|.
160 do { 155 do {
161 if (!run_function_(obj_)) 156 if (!run_function_(obj_))
162 break; 157 break;
163 } while (!stop_event_.Wait(0)); 158 } while (!stop_event_.Wait(0));
164 } 159 }
165 160
166 } // namespace webrtc 161 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/system_wrappers/include/thread_wrapper.h ('k') | webrtc/system_wrappers/source/thread_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698