| OLD | NEW |
| 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" | 24 #include "webrtc/base/platform_thread.h" |
| 25 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" | 25 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
| 26 #include "webrtc/system_wrappers/interface/event_wrapper.h" | 26 #include "webrtc/system_wrappers/include/event_wrapper.h" |
| 27 #include "webrtc/system_wrappers/interface/sleep.h" | 27 #include "webrtc/system_wrappers/include/sleep.h" |
| 28 #include "webrtc/system_wrappers/interface/trace.h" | 28 #include "webrtc/system_wrappers/include/trace.h" |
| 29 | 29 |
| 30 namespace webrtc { | 30 namespace webrtc { |
| 31 namespace { | 31 namespace { |
| 32 struct ThreadAttributes { | 32 struct ThreadAttributes { |
| 33 ThreadAttributes() { pthread_attr_init(&attr); } | 33 ThreadAttributes() { pthread_attr_init(&attr); } |
| 34 ~ThreadAttributes() { pthread_attr_destroy(&attr); } | 34 ~ThreadAttributes() { pthread_attr_destroy(&attr); } |
| 35 pthread_attr_t* operator&() { return &attr; } | 35 pthread_attr_t* operator&() { return &attr; } |
| 36 pthread_attr_t attr; | 36 pthread_attr_t attr; |
| 37 }; | 37 }; |
| 38 } // namespace | 38 } // namespace |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 // It's a requirement that for successful thread creation that the run | 157 // It's a requirement that for successful thread creation that the run |
| 158 // function be called at least once (see RunFunctionIsCalled unit test), | 158 // function be called at least once (see RunFunctionIsCalled unit test), |
| 159 // so to fullfill that requirement, we use a |do| loop and not |while|. | 159 // so to fullfill that requirement, we use a |do| loop and not |while|. |
| 160 do { | 160 do { |
| 161 if (!run_function_(obj_)) | 161 if (!run_function_(obj_)) |
| 162 break; | 162 break; |
| 163 } while (!stop_event_.Wait(0)); | 163 } while (!stop_event_.Wait(0)); |
| 164 } | 164 } |
| 165 | 165 |
| 166 } // namespace webrtc | 166 } // namespace webrtc |
| OLD | NEW |