1 // Test program that allows to verify whether Drd works fine for programs that 2 // use the boost::thread, boost::mutex and boost::condition classes. 3 4 5 #include <boost/thread/condition.hpp> 6 #include <boost/thread/mutex.hpp> 7 #include <boost/thread/thread.hpp> 8 #include <iostream> 9 10 11 static boost::condition s_cva; 12 static boost::mutex s_m; 13 14 thread_func(void)15static void thread_func(void) 16 { 17 std::cerr << "Thread 2.\n"; 18 boost::mutex::scoped_lock sl(s_m); 19 s_cva.notify_all(); 20 s_cva.wait(sl); 21 } 22 main(int argc,char ** argv)23int main(int argc, char** argv) 24 { 25 std::cerr << "Thread 1.\n"; 26 boost::mutex::scoped_lock sl(s_m); 27 boost::thread t(thread_func); 28 s_cva.wait(sl); 29 s_cva.notify_all(); 30 sl.unlock(); 31 t.join(); 32 std::cerr << "Finished.\n"; 33 return 0; 34 } 35