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

Unified Diff: webrtc/system_wrappers/source/condition_variable_posix.cc

Issue 1601743004: Make CriticalSectionWrapper non-virtual (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Improve comment Created 4 years, 11 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
Index: webrtc/system_wrappers/source/condition_variable_posix.cc
diff --git a/webrtc/system_wrappers/source/condition_variable_posix.cc b/webrtc/system_wrappers/source/condition_variable_posix.cc
index b21304245cd832d70ff33c23ee2403327c2f076f..c2de4e36a06b8c20fc6e5cb8dca924d3c36a7c81 100644
--- a/webrtc/system_wrappers/source/condition_variable_posix.cc
+++ b/webrtc/system_wrappers/source/condition_variable_posix.cc
@@ -10,6 +10,8 @@
#include "webrtc/system_wrappers/source/condition_variable_posix.h"
+#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
+
#include <errno.h>
#if defined(WEBRTC_LINUX)
#include <time.h>
@@ -17,8 +19,6 @@
#include <sys/time.h>
#endif
-#include "webrtc/system_wrappers/source/critical_section_posix.h"
-
namespace webrtc {
ConditionVariableWrapper* ConditionVariablePosix::Create() {
@@ -70,9 +70,7 @@ ConditionVariablePosix::~ConditionVariablePosix() {
}
void ConditionVariablePosix::SleepCS(CriticalSectionWrapper& crit_sect) {
- CriticalSectionPosix* cs = reinterpret_cast<CriticalSectionPosix*>(
- &crit_sect);
- pthread_cond_wait(&cond_, &cs->mutex_);
+ pthread_cond_wait(&cond_, &crit_sect.mutex_);
}
bool ConditionVariablePosix::SleepCS(CriticalSectionWrapper& crit_sect,
@@ -85,9 +83,6 @@ bool ConditionVariablePosix::SleepCS(CriticalSectionWrapper& crit_sect,
const int NANOSECONDS_PER_SECOND = 1000000000;
const int NANOSECONDS_PER_MILLISECOND = 1000000;
- CriticalSectionPosix* cs = reinterpret_cast<CriticalSectionPosix*>(
- &crit_sect);
-
if (max_time_inMS != INFINITE) {
timespec ts;
#ifndef WEBRTC_MAC
@@ -113,10 +108,10 @@ bool ConditionVariablePosix::SleepCS(CriticalSectionWrapper& crit_sect,
ts.tv_sec += ts.tv_nsec / NANOSECONDS_PER_SECOND;
ts.tv_nsec %= NANOSECONDS_PER_SECOND;
}
- const int res = pthread_cond_timedwait(&cond_, &cs->mutex_, &ts);
+ const int res = pthread_cond_timedwait(&cond_, &crit_sect.mutex_, &ts);
return (res == ETIMEDOUT) ? false : true;
} else {
- pthread_cond_wait(&cond_, &cs->mutex_);
+ pthread_cond_wait(&cond_, &crit_sect.mutex_);
return true;
}
}
« no previous file with comments | « webrtc/system_wrappers/source/condition_variable_native_win.cc ('k') | webrtc/system_wrappers/source/critical_section.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698