OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 87 |
88 ThreadRunFunction const run_function_; | 88 ThreadRunFunction const run_function_; |
89 void* const obj_; | 89 void* const obj_; |
90 // TODO(pbos): Make sure call sites use string literals and update to a const | 90 // TODO(pbos): Make sure call sites use string literals and update to a const |
91 // char* instead of a std::string. | 91 // char* instead of a std::string. |
92 const std::string name_; | 92 const std::string name_; |
93 rtc::ThreadChecker thread_checker_; | 93 rtc::ThreadChecker thread_checker_; |
94 #if defined(WEBRTC_WIN) | 94 #if defined(WEBRTC_WIN) |
95 static DWORD WINAPI StartThread(void* param); | 95 static DWORD WINAPI StartThread(void* param); |
96 | 96 |
97 bool stop_; | 97 bool stop_ = false; |
98 HANDLE thread_; | 98 HANDLE thread_ = nullptr; |
99 DWORD thread_id_; | 99 DWORD thread_id_ = 0; |
100 #else | 100 #else |
101 static void* StartThread(void* param); | 101 static void* StartThread(void* param); |
102 | 102 |
103 rtc::Event stop_event_; | 103 // An atomic flag that we use to stop the thread. Only modified on the |
104 | 104 // controlling thread and checked on the worker thread. |
105 pthread_t thread_; | 105 volatile int stop_flag_ = 0; |
| 106 pthread_t thread_ = 0; |
106 #endif // defined(WEBRTC_WIN) | 107 #endif // defined(WEBRTC_WIN) |
107 RTC_DISALLOW_COPY_AND_ASSIGN(PlatformThread); | 108 RTC_DISALLOW_COPY_AND_ASSIGN(PlatformThread); |
108 }; | 109 }; |
109 | 110 |
110 } // namespace rtc | 111 } // namespace rtc |
111 | 112 |
112 #endif // WEBRTC_BASE_PLATFORM_THREAD_H_ | 113 #endif // WEBRTC_BASE_PLATFORM_THREAD_H_ |
OLD | NEW |