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

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

Issue 2047433004: content: Add heartbeat trace for CategorizedWorkerPool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
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 <errno.h> 7 #include <errno.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <sys/time.h> 9 #include <sys/time.h>
10 10
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 #if DCHECK_IS_ON() 66 #if DCHECK_IS_ON()
67 user_lock_->CheckHeldAndUnmark(); 67 user_lock_->CheckHeldAndUnmark();
68 #endif 68 #endif
69 int rv = pthread_cond_wait(&condition_, user_mutex_); 69 int rv = pthread_cond_wait(&condition_, user_mutex_);
70 DCHECK_EQ(0, rv); 70 DCHECK_EQ(0, rv);
71 #if DCHECK_IS_ON() 71 #if DCHECK_IS_ON()
72 user_lock_->CheckUnheldAndMark(); 72 user_lock_->CheckUnheldAndMark();
73 #endif 73 #endif
74 } 74 }
75 75
76 void ConditionVariable::TimedWait(const TimeDelta& max_time) { 76 bool ConditionVariable::TimedWait(const TimeDelta& max_time) {
77 base::ThreadRestrictions::AssertWaitAllowed(); 77 base::ThreadRestrictions::AssertWaitAllowed();
78 int64_t usecs = max_time.InMicroseconds(); 78 int64_t usecs = max_time.InMicroseconds();
79 struct timespec relative_time; 79 struct timespec relative_time;
80 relative_time.tv_sec = usecs / Time::kMicrosecondsPerSecond; 80 relative_time.tv_sec = usecs / Time::kMicrosecondsPerSecond;
81 relative_time.tv_nsec = 81 relative_time.tv_nsec =
82 (usecs % Time::kMicrosecondsPerSecond) * Time::kNanosecondsPerMicrosecond; 82 (usecs % Time::kMicrosecondsPerSecond) * Time::kNanosecondsPerMicrosecond;
83 83
84 #if DCHECK_IS_ON() 84 #if DCHECK_IS_ON()
85 user_lock_->CheckHeldAndUnmark(); 85 user_lock_->CheckHeldAndUnmark();
86 #endif 86 #endif
(...skipping 25 matching lines...) Expand all
112 112
113 #if defined(OS_ANDROID) && defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC) 113 #if defined(OS_ANDROID) && defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC)
114 int rv = pthread_cond_timedwait_monotonic_np( 114 int rv = pthread_cond_timedwait_monotonic_np(
115 &condition_, user_mutex_, &absolute_time); 115 &condition_, user_mutex_, &absolute_time);
116 #else 116 #else
117 int rv = pthread_cond_timedwait(&condition_, user_mutex_, &absolute_time); 117 int rv = pthread_cond_timedwait(&condition_, user_mutex_, &absolute_time);
118 #endif // OS_ANDROID && HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC 118 #endif // OS_ANDROID && HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC
119 #endif // OS_MACOSX 119 #endif // OS_MACOSX
120 120
121 DCHECK(rv == 0 || rv == ETIMEDOUT); 121 DCHECK(rv == 0 || rv == ETIMEDOUT);
122
122 #if DCHECK_IS_ON() 123 #if DCHECK_IS_ON()
123 user_lock_->CheckUnheldAndMark(); 124 user_lock_->CheckUnheldAndMark();
124 #endif 125 #endif
126
127 // Return true if timeout occurred.
128 return rv == ETIMEDOUT;
125 } 129 }
126 130
127 void ConditionVariable::Broadcast() { 131 void ConditionVariable::Broadcast() {
128 int rv = pthread_cond_broadcast(&condition_); 132 int rv = pthread_cond_broadcast(&condition_);
129 DCHECK_EQ(0, rv); 133 DCHECK_EQ(0, rv);
130 } 134 }
131 135
132 void ConditionVariable::Signal() { 136 void ConditionVariable::Signal() {
133 int rv = pthread_cond_signal(&condition_); 137 int rv = pthread_cond_signal(&condition_);
134 DCHECK_EQ(0, rv); 138 DCHECK_EQ(0, rv);
135 } 139 }
136 140
137 } // namespace base 141 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698