void f2() { time_point t0 = Clock::now(); assert(m.try_lock_until(Clock::now() + ms(250)) == false); time_point t1 = Clock::now(); ns d = t1 - t0 - ms(250); assert(d < ms(50)); // within 50ms }
void f1() { time_point t0 = Clock::now(); assert(m.try_lock_until(Clock::now() + ms(300)) == true); time_point t1 = Clock::now(); assert(m.try_lock()); m.unlock(); m.unlock(); ns d = t1 - t0 - ms(250); assert(d < ms(50)); // within 50ms }