5 #include <boost/chrono.hpp>
6 #include <boost/thread.hpp>
12 typedef boost::chrono::steady_clock::time_point
TimePoint;
17 static boost::chrono::steady_clock::time_point
now() {
18 std::cout <<
"TestIMPL:: returning now = " << (
_epoch -
_now).count() << std::endl;
21 static boost::chrono::steady_clock::time_point
_now;
22 static boost::chrono::steady_clock::time_point
_epoch;
24 template<
class Rep,
class Period>
25 static void setTime(boost::chrono::duration<Rep, Period> timeSinceMyEpoch) {
53 namespace testable_rebot_sleep {
54 boost::chrono::steady_clock::time_point
now() {
55 std::cout <<
"function TestIMPL:: returning now = "
65 void sleep_until(boost::chrono::steady_clock::time_point t) {
79 std::cout <<
"application unlocked" << std::endl;
87 std::cout <<
"application yielding..." << std::endl;
89 boost::this_thread::interruption_point();
90 boost::this_thread::yield();
93 std::cout <<
"application trying to lock" << std::endl;
98 std::cout <<
"application locked, mayget is false" << std::endl;
104 std::cout <<
"test unlocked" << std::endl;
109 std::cout <<
"test yielding..." << std::endl;
111 boost::this_thread::yield();
114 std::cout <<
"test trying to lock" << std::endl;
121 std::cout <<
"test locked, mayget is true" << std::endl;
124 template<
class Rep,
class Period>
125 void advance_until(boost::chrono::duration<Rep, Period> targetTimeRelativeMyEpoch) {
129 std::cout <<
"next wakeup requested for "
146 boost::this_thread::yield();
148 boost::this_thread::yield();
154 std::cout <<
"test locked initially , mayget is true" << std::endl;