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

Side by Side Diff: webrtc/system_wrappers/source/thread_win.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 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) 2011 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2011 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_win.h" 11 #include "webrtc/system_wrappers/source/thread_win.h"
12 12
13 #include <process.h> 13 #include <process.h>
14 #include <stdio.h> 14 #include <stdio.h>
15 #include <windows.h> 15 #include <windows.h>
16 16
17 #include "webrtc/base/checks.h" 17 #include "webrtc/base/checks.h"
18 #include "webrtc/base/platform_thread.h"
19 #include "webrtc/system_wrappers/include/trace.h" 18 #include "webrtc/system_wrappers/include/trace.h"
20 19
21 namespace webrtc { 20 namespace webrtc {
22 namespace { 21 namespace {
23 void CALLBACK RaiseFlag(ULONG_PTR param) { 22 void CALLBACK RaiseFlag(ULONG_PTR param) {
24 *reinterpret_cast<bool*>(param) = true; 23 *reinterpret_cast<bool*>(param) = true;
25 } 24 }
26 } 25 }
27 26
28 ThreadWindows::ThreadWindows(ThreadRunFunction func, void* obj, 27 ThreadWindows::ThreadWindows(ThreadRunFunction func, void* obj,
29 const char* thread_name) 28 const char* thread_name)
30 : run_function_(func), 29 : run_function_(func),
31 obj_(obj), 30 obj_(obj),
32 stop_(false), 31 stop_(false),
33 thread_(NULL), 32 thread_(NULL),
34 name_(thread_name ? thread_name : "webrtc") { 33 name_(thread_name ? thread_name : "webrtc") {
35 RTC_DCHECK(func); 34 RTC_DCHECK(func);
36 } 35 }
37 36
38 ThreadWindows::~ThreadWindows() { 37 ThreadWindows::~ThreadWindows() {
39 RTC_DCHECK(main_thread_.CalledOnValidThread()); 38 RTC_DCHECK(main_thread_.CalledOnValidThread());
40 RTC_DCHECK(!thread_); 39 RTC_DCHECK(!thread_);
41 } 40 }
42 41
43 // static 42 // static
44 uint32_t ThreadWrapper::GetThreadId() {
45 return GetCurrentThreadId();
46 }
47
48 // static
49 DWORD WINAPI ThreadWindows::StartThread(void* param) { 43 DWORD WINAPI ThreadWindows::StartThread(void* param) {
50 static_cast<ThreadWindows*>(param)->Run(); 44 static_cast<ThreadWindows*>(param)->Run();
51 return 0; 45 return 0;
52 } 46 }
53 47
54 bool ThreadWindows::Start() { 48 bool ThreadWindows::Start() {
55 RTC_DCHECK(main_thread_.CalledOnValidThread()); 49 RTC_DCHECK(main_thread_.CalledOnValidThread());
56 RTC_DCHECK(!thread_); 50 RTC_DCHECK(!thread_);
57 51
58 stop_ = false; 52 stop_ = false;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // Start, there should be at least one call to the run function. So we 92 // Start, there should be at least one call to the run function. So we
99 // call the function before checking |stop_|. 93 // call the function before checking |stop_|.
100 if (!run_function_(obj_)) 94 if (!run_function_(obj_))
101 break; 95 break;
102 // Alertable sleep to permit RaiseFlag to run and update |stop_|. 96 // Alertable sleep to permit RaiseFlag to run and update |stop_|.
103 SleepEx(0, true); 97 SleepEx(0, true);
104 } while (!stop_); 98 } while (!stop_);
105 } 99 }
106 100
107 } // namespace webrtc 101 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/system_wrappers/source/thread_posix.cc ('k') | webrtc/system_wrappers/source/trace_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698