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

Side by Side Diff: base/synchronization/condition_variable_win.cc

Issue 2341773003: Add Some Comments to the Timeout Checks on Condition Variables (Closed)
Patch Set: Created 4 years, 3 months 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
« no previous file with comments | « base/synchronization/condition_variable_posix.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/synchronization/condition_variable.h" 5 #include "base/synchronization/condition_variable.h"
6 6
7 #include "base/synchronization/lock.h" 7 #include "base/synchronization/lock.h"
8 #include "base/threading/thread_restrictions.h" 8 #include "base/threading/thread_restrictions.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 10
(...skipping 17 matching lines...) Expand all
28 28
29 void ConditionVariable::TimedWait(const TimeDelta& max_time) { 29 void ConditionVariable::TimedWait(const TimeDelta& max_time) {
30 base::ThreadRestrictions::AssertWaitAllowed(); 30 base::ThreadRestrictions::AssertWaitAllowed();
31 DWORD timeout = static_cast<DWORD>(max_time.InMilliseconds()); 31 DWORD timeout = static_cast<DWORD>(max_time.InMilliseconds());
32 32
33 #if DCHECK_IS_ON() 33 #if DCHECK_IS_ON()
34 user_lock_->CheckHeldAndUnmark(); 34 user_lock_->CheckHeldAndUnmark();
35 #endif 35 #endif
36 36
37 if (!SleepConditionVariableSRW(&cv_, srwlock_, timeout, 0)) { 37 if (!SleepConditionVariableSRW(&cv_, srwlock_, timeout, 0)) {
38 // On failure, we only expect the CV to timeout. Any other error value means
39 // that we've unexpectedly woken up.
40 // Note that WAIT_TIMEOUT != ERROR_TIMEOUT. WAIT_TIMEOUT is used with the
41 // WaitFor* family of functions as a direct return value. ERROR_TIMEOUT is
42 // used with GetLastError().
38 DCHECK_EQ(static_cast<DWORD>(ERROR_TIMEOUT), GetLastError()); 43 DCHECK_EQ(static_cast<DWORD>(ERROR_TIMEOUT), GetLastError());
39 } 44 }
40 45
41 #if DCHECK_IS_ON() 46 #if DCHECK_IS_ON()
42 user_lock_->CheckUnheldAndMark(); 47 user_lock_->CheckUnheldAndMark();
43 #endif 48 #endif
44 } 49 }
45 50
46 void ConditionVariable::Broadcast() { 51 void ConditionVariable::Broadcast() {
47 WakeAllConditionVariable(&cv_); 52 WakeAllConditionVariable(&cv_);
48 } 53 }
49 54
50 void ConditionVariable::Signal() { 55 void ConditionVariable::Signal() {
51 WakeConditionVariable(&cv_); 56 WakeConditionVariable(&cv_);
52 } 57 }
53 58
54 } // namespace base 59 } // namespace base
OLDNEW
« no previous file with comments | « base/synchronization/condition_variable_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698