Chromium Code Reviews| Index: base/synchronization/waitable_event_posix.cc |
| diff --git a/base/synchronization/waitable_event_posix.cc b/base/synchronization/waitable_event_posix.cc |
| index 696ffc7a02abe5a1c21e429032b217fd7f142c91..57e5db10490e93c5aa274f82fc6e6912b671e866 100644 |
| --- a/base/synchronization/waitable_event_posix.cc |
| +++ b/base/synchronization/waitable_event_posix.cc |
| @@ -151,14 +151,14 @@ class SyncWaiter : public WaitableEvent::Waiter { |
| }; |
| void WaitableEvent::Wait() { |
| - bool result = TimedWait(TimeDelta::FromSeconds(-1)); |
| + bool result = TimedWait(TimeDelta::Max()); |
| DCHECK(result) << "TimedWait() should never fail with infinite timeout"; |
| } |
| bool WaitableEvent::TimedWait(const TimeDelta& max_time) { |
| + DCHECK(max_time >= TimeDelta()); |
|
Lei Zhang
2015/03/25 01:36:27
Can we use DCHECK_GE() in both impls?
Also mentio
rvargas (doing something else)
2015/03/26 19:37:27
Done.
|
| base::ThreadRestrictions::AssertWaitAllowed(); |
| const TimeTicks end_time(TimeTicks::Now() + max_time); |
| - const bool finite_time = max_time.ToInternalValue() >= 0; |
| kernel_->lock_.Acquire(); |
| if (kernel_->signaled_) { |
| @@ -184,7 +184,7 @@ bool WaitableEvent::TimedWait(const TimeDelta& max_time) { |
| for (;;) { |
| const TimeTicks current_time(TimeTicks::Now()); |
| - if (sw.fired() || (finite_time && current_time >= end_time)) { |
| + if (sw.fired() || current_time >= end_time) { |
| const bool return_value = sw.fired(); |
| // We can't acquire @lock_ before releasing the SyncWaiter lock (because |
| @@ -207,12 +207,7 @@ bool WaitableEvent::TimedWait(const TimeDelta& max_time) { |
| return return_value; |
| } |
| - if (finite_time) { |
| - const TimeDelta max_wait(end_time - current_time); |
| - sw.cv()->TimedWait(max_wait); |
| - } else { |
| - sw.cv()->Wait(); |
| - } |
| + sw.cv()->TimedWait(end_time - current_time); |
| } |
| } |