#include #include #include template class fixed_point_clock { public: typedef typename Clock::duration duration; typedef typename duration::rep rep; typedef typename duration::period period; typedef boost::chrono::time_point time_point; static time_point now() { if (!fixedPoint.is_initialized()) fixedPoint = boost::in_place(Clock::now().time_since_epoch()); return *fixedPoint; } private: static boost::optional fixedPoint; }; template boost::optional::time_point> fixed_point_clock::fixedPoint = boost::none; int main() { using namespace std; //any clock can be used, important that we get: t - Clock::t == -1 milliseconds //it easier to achieve with fixed_point_clock //typedef boost::chrono::system_clock clock; typedef fixed_point_clock clock; boost::condition_variable var; boost::mutex mut; boost::mutex::scoped_lock lk(mut); auto until = clock::now() - boost::chrono::milliseconds(1); //in wait_until: " do_wait(lock, ceil(t-Clock::now()).count()) " //if ceil(t-Clock::now()).count() == -1 then boost::detail::timeout::milliseconds == 0xf...f, //witch is a special value - is_sentinel(), it is checked in win32/thread.cpp: this_thread::interruptible_wait var.wait_until(lk, until); //infinite wait cout << "done" << endl; return EXIT_SUCCESS; }