OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 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 13 matching lines...) Expand all Loading... |
24 | 24 |
25 namespace rtc { | 25 namespace rtc { |
26 | 26 |
27 #if defined(WEBRTC_WIN) | 27 #if defined(WEBRTC_WIN) |
28 | 28 |
29 Event::Event(bool manual_reset, bool initially_signaled) { | 29 Event::Event(bool manual_reset, bool initially_signaled) { |
30 event_handle_ = ::CreateEvent(NULL, // Security attributes. | 30 event_handle_ = ::CreateEvent(NULL, // Security attributes. |
31 manual_reset, | 31 manual_reset, |
32 initially_signaled, | 32 initially_signaled, |
33 NULL); // Name. | 33 NULL); // Name. |
34 CHECK(event_handle_); | 34 RTC_CHECK(event_handle_); |
35 } | 35 } |
36 | 36 |
37 Event::~Event() { | 37 Event::~Event() { |
38 CloseHandle(event_handle_); | 38 CloseHandle(event_handle_); |
39 } | 39 } |
40 | 40 |
41 void Event::Set() { | 41 void Event::Set() { |
42 SetEvent(event_handle_); | 42 SetEvent(event_handle_); |
43 } | 43 } |
44 | 44 |
45 void Event::Reset() { | 45 void Event::Reset() { |
46 ResetEvent(event_handle_); | 46 ResetEvent(event_handle_); |
47 } | 47 } |
48 | 48 |
49 bool Event::Wait(int milliseconds) { | 49 bool Event::Wait(int milliseconds) { |
50 DWORD ms = (milliseconds == kForever) ? INFINITE : milliseconds; | 50 DWORD ms = (milliseconds == kForever) ? INFINITE : milliseconds; |
51 return (WaitForSingleObject(event_handle_, ms) == WAIT_OBJECT_0); | 51 return (WaitForSingleObject(event_handle_, ms) == WAIT_OBJECT_0); |
52 } | 52 } |
53 | 53 |
54 #elif defined(WEBRTC_POSIX) | 54 #elif defined(WEBRTC_POSIX) |
55 | 55 |
56 Event::Event(bool manual_reset, bool initially_signaled) | 56 Event::Event(bool manual_reset, bool initially_signaled) |
57 : is_manual_reset_(manual_reset), | 57 : is_manual_reset_(manual_reset), |
58 event_status_(initially_signaled) { | 58 event_status_(initially_signaled) { |
59 CHECK(pthread_mutex_init(&event_mutex_, NULL) == 0); | 59 RTC_CHECK(pthread_mutex_init(&event_mutex_, NULL) == 0); |
60 CHECK(pthread_cond_init(&event_cond_, NULL) == 0); | 60 RTC_CHECK(pthread_cond_init(&event_cond_, NULL) == 0); |
61 } | 61 } |
62 | 62 |
63 Event::~Event() { | 63 Event::~Event() { |
64 pthread_mutex_destroy(&event_mutex_); | 64 pthread_mutex_destroy(&event_mutex_); |
65 pthread_cond_destroy(&event_cond_); | 65 pthread_cond_destroy(&event_cond_); |
66 } | 66 } |
67 | 67 |
68 void Event::Set() { | 68 void Event::Set() { |
69 pthread_mutex_lock(&event_mutex_); | 69 pthread_mutex_lock(&event_mutex_); |
70 event_status_ = true; | 70 event_status_ = true; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 event_status_ = false; | 126 event_status_ = false; |
127 | 127 |
128 pthread_mutex_unlock(&event_mutex_); | 128 pthread_mutex_unlock(&event_mutex_); |
129 | 129 |
130 return (error == 0); | 130 return (error == 0); |
131 } | 131 } |
132 | 132 |
133 #endif | 133 #endif |
134 | 134 |
135 } // namespace rtc | 135 } // namespace rtc |
OLD | NEW |