Ejemplo n.º 1
0
 BOOLEAN try_get ()
 {
    try
    {
       return _m.timed_lock ( boost::posix_time::milliseconds ( 0 ) ) ;
    }
    catch(...)
    {
       SDB_ASSERT ( FALSE, "SLatch try get failed" ) ;
    }
    return FALSE ;
 }
Ejemplo n.º 2
0
void thread2_func()
{
  int i (0);
  while (true)
  {
    if (mutex.timed_lock(boost::posix_time::milliseconds(500)))
    {
      std::cout << "Unique lock acquired" << std::endl
        << "Test successful" << std::endl;
      mutex.unlock();
      break;
    }
    ++i;
    if (i == 100)
    {
      std::cout << "Test failed. App is deadlocked" << std::endl;
      break;
    }
    boost::this_thread::sleep(boost::posix_time::seconds(1));
  }
}