Пример #1
0
int main()
{
  m.lock();
  boost::thread t(f);
  m.unlock();
  t.join();

  return boost::report_errors();
}
Пример #2
0
void f()
{
#if defined BOOST_THREAD_USES_CHRONO
  time_point t0 = Clock::now();
  m.lock();
  time_point t1 = Clock::now();
  m.lock();
  m.unlock();
  m.unlock();
  ns d = t1 - t0 ;
  // This test is spurious as it depends on the time the thread system switches the threads
  BOOST_TEST(d < ns(2500000)); // within 2.5ms
#else
  //time_point t0 = Clock::now();
  m.lock();
  //time_point t1 = Clock::now();
  m.lock();
  m.unlock();
  m.unlock();
  //ns d = t1 - t0 ;
  // This test is spurious as it depends on the time the thread system switches the threads
  //BOOST_TEST(d < ns(2500000)); // within 2.5ms
#endif
}