blob: fbf9dbd398eef70a5537dc0f7fe05d29a3511ad6 [file] [log] [blame]
bartb2abfdd2009-03-11 19:12:06 +00001// 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
bart61e34a12008-11-10 18:54:46 +00005#include <boost/thread/condition.hpp>
6#include <boost/thread/mutex.hpp>
7#include <boost/thread/thread.hpp>
8#include <iostream>
9
10
11static boost::condition s_cva;
12static boost::mutex s_m;
13
14
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
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}