Address comments from previous review round for rtc::Event.

R=andresp@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/35049004

Cr-Commit-Position: refs/heads/master@{#8313}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8313 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
tommi@webrtc.org 2015-02-10 12:27:48 +00:00
parent f4c10d24dc
commit 1a072f93eb
2 changed files with 12 additions and 9 deletions

View File

@ -46,8 +46,8 @@ void Event::Reset() {
ResetEvent(event_handle_);
}
bool Event::Wait(int cms) {
DWORD ms = (cms == kForever) ? INFINITE : cms;
bool Event::Wait(int milliseconds) {
DWORD ms = (milliseconds == kForever) ? INFINITE : milliseconds;
return (WaitForSingleObject(event_handle_, ms) == WAIT_OBJECT_0);
}
@ -78,11 +78,11 @@ void Event::Reset() {
pthread_mutex_unlock(&event_mutex_);
}
bool Event::Wait(int cms) {
bool Event::Wait(int milliseconds) {
pthread_mutex_lock(&event_mutex_);
int error = 0;
if (cms != kForever) {
if (milliseconds != kForever) {
// Converting from seconds and microseconds (1e-6) plus
// milliseconds (1e-3) to seconds and nanoseconds (1e-9).
@ -90,14 +90,14 @@ bool Event::Wait(int cms) {
#if HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE
// Use relative time version, which tends to be more efficient for
// pthread implementations where provided (like on Android).
ts.tv_sec = cms / 1000;
ts.tv_nsec = (cms % 1000) * 1000000;
ts.tv_sec = milliseconds / 1000;
ts.tv_nsec = (milliseconds % 1000) * 1000000;
#else
struct timeval tv;
gettimeofday(&tv, NULL);
ts.tv_sec = tv.tv_sec + (cms / 1000);
ts.tv_nsec = tv.tv_usec * 1000 + (cms % 1000) * 1000000;
ts.tv_sec = tv.tv_sec + (milliseconds / 1000);
ts.tv_nsec = tv.tv_usec * 1000 + (milliseconds % 1000) * 1000000;
// Handle overflow.
if (ts.tv_nsec >= 1000000000) {

View File

@ -32,7 +32,10 @@ class Event {
void Set();
void Reset();
bool Wait(int cms);
// Wait for the event to become signaled, for the specified number of
// |milliseconds|. To wait indefinetly, pass kForever.
bool Wait(int milliseconds);
private:
#if defined(WEBRTC_WIN)