1686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org/*
2f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgSource:
3f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orghttp://www1.cse.wustl.edu/~schmidt/ACE-copying.html
4f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.org
5f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgLicense:
6f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgCopyright and Licensing Information for ACE(TM), TAO(TM), CIAO(TM), DAnCE(TM),
7f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.organd CoSMIC(TM)
8f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.org
9f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgACE(TM), TAO(TM), CIAO(TM), DAnCE>(TM), and CoSMIC(TM) (henceforth referred to
10f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgas "DOC software") are copyrighted by Douglas C. Schmidt and his research
11f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orggroup at Washington University, University of California, Irvine, and
12f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgVanderbilt University, Copyright (c) 1993-2009, all rights reserved. Since DOC
13f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgsoftware is open-source, freely available software, you are free to use,
14f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgmodify, copy, and distribute--perpetually and irrevocably--the DOC software
15f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgsource code and object code produced from the source, as well as copy and
16f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgdistribute modified versions of this software. You must, however, include this
17f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgcopyright statement along with any code built using DOC software that you
18f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgrelease. No copyright statement needs to be provided if you just ship binary
19f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgexecutables of your software products.
20f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgYou can use DOC software in commercial and/or binary software releases and are
21f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgunder no obligation to redistribute any of your source code that is built
22f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgusing DOC software. Note, however, that you may not misappropriate the DOC
23f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgsoftware code, such as copyrighting it yourself or claiming authorship of the
24f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgDOC software code, in a way that will prevent DOC software from being
25f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgdistributed freely using an open-source development model. You needn't inform
26f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.organyone that you're using DOC software in your software, though we encourage
27f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgyou to let us know so we can promote your project in the DOC software success
28f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgstories.
29f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.org
30f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgThe ACE, TAO, CIAO, DAnCE, and CoSMIC web sites are maintained by the DOC
31f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgGroup at the Institute for Software Integrated Systems (ISIS) and the Center
32f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgfor Distributed Object Computing of Washington University, St. Louis for the
33f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgdevelopment of open-source software as part of the open-source software
34f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgcommunity. Submissions are provided by the submitter ``as is'' with no
35f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgwarranties whatsoever, including any warranty of merchantability,
36f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgnoninfringement of third party intellectual property, or fitness for any
37f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgparticular purpose. In no event shall the submitter be liable for any direct,
38f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgindirect, special, exemplary, punitive, or consequential damages, including
39f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgwithout limitation, lost profits, even if advised of the possibility of such
40f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgdamages. Likewise, DOC software is provided as is with no warranties of any
41f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgkind, including the warranties of design, merchantability, and fitness for a
42f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgparticular purpose, noninfringement, or arising from a course of dealing,
43f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgusage or trade practice. Washington University, UC Irvine, Vanderbilt
44f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgUniversity, their employees, and students shall have no liability with respect
45f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgto the infringement of copyrights, trade secrets or any patents by DOC
46f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgsoftware or any part thereof. Moreover, in no event will Washington
47f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgUniversity, UC Irvine, or Vanderbilt University, their employees, or students
48f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgbe liable for any lost revenue or profits or other special, indirect and
49f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgconsequential damages.
50f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.org
51f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgDOC software is provided with no support and without any obligation on the
52f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgpart of Washington University, UC Irvine, Vanderbilt University, their
53f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgemployees, or students to assist in its use, correction, modification, or
54f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgenhancement. A number of companies around the world provide commercial support
55f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgfor DOC software, however. DOC software is Y2K-compliant, as long as the
56f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgunderlying OS platform is Y2K-compliant. Likewise, DOC software is compliant
57f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgwith the new US daylight savings rule passed by Congress as "The Energy Policy
58f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgAct of 2005," which established new daylight savings times (DST) rules for the
59f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgUnited States that expand DST as of March 2007. Since DOC software obtains
60f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgtime/date and calendaring information from operating systems users will not be
61f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgaffected by the new DST rules as long as they upgrade their operating systems
62f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgaccordingly.
63f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.org
64f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgThe names ACE(TM), TAO(TM), CIAO(TM), DAnCE(TM), CoSMIC(TM), Washington
65f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgUniversity, UC Irvine, and Vanderbilt University, may not be used to endorse
66f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgor promote products or services derived from this source without express
67f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgwritten permission from Washington University, UC Irvine, or Vanderbilt
68f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgUniversity. This license grants no permission to call products or services
69f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgderived from this source ACE(TM), TAO(TM), CIAO(TM), DAnCE(TM), or CoSMIC(TM),
70f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgnor does it grant permission for the name Washington University, UC Irvine, or
71f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.orgVanderbilt University to appear in their names.
72f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.org*/
73f9c289bafe4901bf3578ff16e662dcfb7aaf20e6andrew@webrtc.org
74686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org/*
75686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org *  This source code contain modifications to the original source code
76686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org *  which can be found here:
77686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org *  http://www.cs.wustl.edu/~schmidt/win32-cv-1.html (section 3.2).
78686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org *  Modifications:
79686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org *  1) Dynamic detection of native support for condition variables.
80686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org *  2) Use of WebRTC defined types and classes. Renaming of some functions.
81686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org *  3) Introduction of a second event for wake all functionality. This prevents
82686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org *     a thread from spinning on the same condition variable, preventing other
83686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org *     threads from waking up.
84686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org */
85686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org
86686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org#include "webrtc/system_wrappers/source/condition_variable_event_win.h"
87686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org#include "webrtc/system_wrappers/source/critical_section_win.h"
88686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org
89686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.orgnamespace webrtc {
90686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org
91686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.orgConditionVariableEventWin::ConditionVariableEventWin() : eventID_(WAKEALL_0) {
92686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  memset(&num_waiters_[0], 0, sizeof(num_waiters_));
93686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org
94686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  InitializeCriticalSection(&num_waiters_crit_sect_);
95686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org
96686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  events_[WAKEALL_0] = CreateEvent(NULL,  // no security attributes
97686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org                                   TRUE,  // manual-reset, sticky event
98686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org                                   FALSE,  // initial state non-signaled
99686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org                                   NULL);  // no name for event
100686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org
101686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  events_[WAKEALL_1] = CreateEvent(NULL,  // no security attributes
102686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org                                   TRUE,  // manual-reset, sticky event
103686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org                                   FALSE,  // initial state non-signaled
104686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org                                   NULL);  // no name for event
105686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org
106686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  events_[WAKE] = CreateEvent(NULL,  // no security attributes
107686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org                              FALSE,  // auto-reset, sticky event
108686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org                              FALSE,  // initial state non-signaled
109686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org                              NULL);  // no name for event
110686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org}
111686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org
112686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.orgConditionVariableEventWin::~ConditionVariableEventWin() {
113686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  CloseHandle(events_[WAKE]);
114686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  CloseHandle(events_[WAKEALL_1]);
115686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  CloseHandle(events_[WAKEALL_0]);
116686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org
117686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  DeleteCriticalSection(&num_waiters_crit_sect_);
118686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org}
119686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org
120686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.orgvoid ConditionVariableEventWin::SleepCS(CriticalSectionWrapper& crit_sect) {
121686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  SleepCS(crit_sect, INFINITE);
122686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org}
123686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org
124686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.orgbool ConditionVariableEventWin::SleepCS(CriticalSectionWrapper& crit_sect,
125686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org                                        unsigned long max_time_in_ms) {
126686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  EnterCriticalSection(&num_waiters_crit_sect_);
127686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org
128686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  // Get the eventID for the event that will be triggered by next
129686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  // WakeAll() call and start waiting for it.
130686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  const EventWakeUpType eventID =
131686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org      (WAKEALL_0 == eventID_) ? WAKEALL_1 : WAKEALL_0;
132686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org
133686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  ++(num_waiters_[eventID]);
134686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  LeaveCriticalSection(&num_waiters_crit_sect_);
135686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org
136686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  CriticalSectionWindows* cs =
137686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org      static_cast<CriticalSectionWindows*>(&crit_sect);
138686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  LeaveCriticalSection(&cs->crit);
139686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  HANDLE events[2];
140686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  events[0] = events_[WAKE];
141686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  events[1] = events_[eventID];
142686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  const DWORD result = WaitForMultipleObjects(2,  // Wait on 2 events.
143686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org                                              events,
144686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org                                              FALSE,  // Wait for either.
145686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org                                              max_time_in_ms);
146686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org
147686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  const bool ret_val = (result != WAIT_TIMEOUT);
148686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org
149686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  EnterCriticalSection(&num_waiters_crit_sect_);
150686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  --(num_waiters_[eventID]);
151686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org
152686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  // Last waiter should only be true for WakeAll(). WakeAll() correspond
153686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  // to position 1 in events[] -> (result == WAIT_OBJECT_0 + 1)
154686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  const bool last_waiter = (result == WAIT_OBJECT_0 + 1) &&
155686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org      (num_waiters_[eventID] == 0);
156686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  LeaveCriticalSection(&num_waiters_crit_sect_);
157686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org
158686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  if (last_waiter) {
159686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org    // Reset/unset the WakeAll() event since all threads have been
160686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org    // released.
161686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org    ResetEvent(events_[eventID]);
162686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  }
163686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org
164686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  EnterCriticalSection(&cs->crit);
165686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  return ret_val;
166686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org}
167686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org
168686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.orgvoid ConditionVariableEventWin::Wake() {
169686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  EnterCriticalSection(&num_waiters_crit_sect_);
170686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  const bool have_waiters = (num_waiters_[WAKEALL_0] > 0) ||
171686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org      (num_waiters_[WAKEALL_1] > 0);
172686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  LeaveCriticalSection(&num_waiters_crit_sect_);
173686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org
174686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  if (have_waiters) {
175686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org    SetEvent(events_[WAKE]);
176686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  }
177686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org}
178686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org
179686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.orgvoid ConditionVariableEventWin::WakeAll() {
180686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  EnterCriticalSection(&num_waiters_crit_sect_);
181686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org
182686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  // Update current WakeAll() event
183686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  eventID_ = (WAKEALL_0 == eventID_) ? WAKEALL_1 : WAKEALL_0;
184686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org
185686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  // Trigger current event
186686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  const EventWakeUpType eventID = eventID_;
187686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  const bool have_waiters = num_waiters_[eventID] > 0;
188686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  LeaveCriticalSection(&num_waiters_crit_sect_);
189686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org
190686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  if (have_waiters) {
191686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org    SetEvent(events_[eventID]);
192686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org  }
193686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org}
194686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org
195686001dd96d382899a021a9b170f5c212589b2dehenrike@webrtc.org}  // namespace webrtc
196