Ticket #6959: thread_sleep.patch

File thread_sleep.patch, 1.8 KB (added by Niklas Angare <li51ckf02@…>, 10 years ago)
  • libs/thread/test/threads/this_thread/sleep_until/sleep_until_pass.cpp

     
    1616// thread::id this_thread::get_id();
    1717
    1818#include <boost/thread/thread.hpp>
    19 #include <cstdlib>
     19#include <algorithm>
    2020
    2121#include <boost/detail/lightweight_test.hpp>
    2222
     
    3535  boost::chrono::nanoseconds err = ms / 100;
    3636  // The time slept is within 1% of 500ms
    3737  // This test is spurious as it depends on the time the thread system switches the threads
    38   BOOST_TEST(std::abs(static_cast<long>(ns.count())) < (err+boost::chrono::milliseconds(1000)).count());
     38  BOOST_TEST(std::max(ns, -ns) < (err+boost::chrono::milliseconds(1000)));
    3939
    4040}
    4141
  • libs/thread/test/threads/this_thread/sleep_for/sleep_for_pass.cpp

     
    1616// thread::id this_thread::get_id();
    1717
    1818#include <boost/thread/thread.hpp>
    19 #include <cstdlib>
     19#include <algorithm>
    2020
    2121#include <boost/detail/lightweight_test.hpp>
    2222
     
    3535  boost::chrono::nanoseconds err = ms / 100;
    3636  // The time slept is within 1% of 500ms
    3737  // This test is spurious as it depends on the time the thread system switches the threads
    38   BOOST_TEST(std::abs(static_cast<long>(ns.count())) < (err+boost::chrono::milliseconds(1000)).count());
     38  BOOST_TEST(std::max(ns, -ns) < (err/*+boost::chrono::milliseconds(1000)*/));
    3939  return boost::report_errors();
    4040
    4141}