bool Mutex::AwaitImpl(const Condition &cond, int64 end_time) { // end_time is milliseconds since the epoch. A value of zero indicates no // timeout. while (!cond.Eval() && (end_time == 0 || GetCurrentTimeMillis() < end_time)) { Unlock(); // Yield the rest of our CPU timeslice before reacquiring the lock. // Otherwise we'll spin pointlessly here, hurting performance. // (The Condition cannot possibly change when no other thread runs.) ThreadYield(); Lock(); } return cond.Eval(); }