inline void wait_until( unique_lock<mutex>& lk, chrono::time_point<chrono::system_clock, chrono::nanoseconds> tp) { using namespace chrono; nanoseconds d = tp.time_since_epoch(); timespec ts; seconds s = duration_cast<seconds>(d); ts.tv_sec = static_cast<long>(s.count()); ts.tv_nsec = static_cast<long>((d - s).count()); do_timed_wait(lk, ts); }
cv_status wait_until( unique_lock<mutex>& lock, const chrono::time_point<chrono::system_clock, Duration>& t) { using namespace chrono; typedef time_point<system_clock, nanoseconds> nano_sys_tmpt; wait_until(lock, nano_sys_tmpt(ceil<nanoseconds>(t.time_since_epoch()))); return system_clock::now() < t ? cv_status::no_timeout : cv_status::timeout; }
void condition_variable::__do_timed_wait(unique_lock<mutex>& lk, chrono::time_point<chrono::system_clock, chrono::nanoseconds> tp) { using namespace chrono; if (!lk.owns_lock()) __throw_system_error(EPERM, "condition_variable::timed wait: mutex not locked"); nanoseconds d = tp.time_since_epoch(); timespec ts; seconds s = duration_cast<seconds>(d); ts.tv_sec = static_cast<decltype(ts.tv_sec)>(s.count()); ts.tv_nsec = static_cast<decltype(ts.tv_nsec)>((d - s).count()); int ec = pthread_cond_timedwait(&__cv_, lk.mutex()->native_handle(), &ts); if (ec != 0 && ec != ETIMEDOUT) __throw_system_error(ec, "condition_variable timed_wait failed"); }
mono_platform_timepoint(chrono::time_point<chrono::steady_clock, Duration> const& abs_time) : dur(abs_time.time_since_epoch()) {}
bool try_lock_until(const chrono::time_point<chrono::system_clock, Duration>& t) { using namespace chrono; typedef time_point<chrono::system_clock, chrono::system_clock::duration> sys_tmpt; return try_lock_until(sys_tmpt(chrono::ceil<chrono::system_clock::duration>(t.time_since_epoch()))); }