Add DRD suppression patterns for races triggered by std::ostream
[valgrind.git] / drd / tests / boost_thread.cpp
blobfbf9dbd398eef70a5537dc0f7fe05d29a3511ad6
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.
5 #include <boost/thread/condition.hpp>
6 #include <boost/thread/mutex.hpp>
7 #include <boost/thread/thread.hpp>
8 #include <iostream>
11 static boost::condition s_cva;
12 static boost::mutex s_m;
15 static void thread_func(void)
17 std::cerr << "Thread 2.\n";
18 boost::mutex::scoped_lock sl(s_m);
19 s_cva.notify_all();
20 s_cva.wait(sl);
23 int main(int argc, char** argv)
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;