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

Unified Diff: webrtc/base/event.cc

Issue 1716563003: Reduce the scope of rtc::Event::Wait() locking. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/event.cc
diff --git a/webrtc/base/event.cc b/webrtc/base/event.cc
index a9af20863194c02de5a9234b20966f60089c24ca..0e267dc1ac31a0743613650233229a0e6a12e6d0 100644
--- a/webrtc/base/event.cc
+++ b/webrtc/base/event.cc
@@ -79,14 +79,13 @@ void Event::Reset() {
}
bool Event::Wait(int milliseconds) {
- pthread_mutex_lock(&event_mutex_);
int error = 0;
+ struct timespec ts;
if (milliseconds != kForever) {
// Converting from seconds and microseconds (1e-6) plus
// milliseconds (1e-3) to seconds and nanoseconds (1e-9).
- struct timespec ts;
#if HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE
// Use relative time version, which tends to be more efficient for
// pthread implementations where provided (like on Android).
@@ -105,7 +104,10 @@ bool Event::Wait(int milliseconds) {
ts.tv_nsec -= 1000000000;
}
#endif
+ }
+ pthread_mutex_lock(&event_mutex_);
tommi 2016/02/19 16:40:42 There's a slight change in behavior because of thi
+ if (milliseconds != kForever) {
while (!event_status_ && error == 0) {
#if HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE
error = pthread_cond_timedwait_relative_np(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698