1 /* See also https://bugs.kde.org/show_bug.cgi?id=445504 */
3 #include <condition_variable>
10 using lock_guard
= std::lock_guard
<std::mutex
>;
11 using unique_lock
= std::unique_lock
<std::mutex
>;
16 std::condition_variable cv
;
19 // Call pthread_cond_init() explicitly to let DRD know about 'cv'.
20 pthread_cond_init(cv
.native_handle(), NULL
);
24 void other_thread(state
*sp
) {
26 std::cerr
<< "Other thread: waiting for notify\n";
29 if (s
.cv
.wait_for(l
, std::chrono::seconds(3)) !=
30 std::cv_status::timeout
) {
31 std::cerr
<< "Other thread: notified\n";
41 auto future
= std::async(std::launch::async
, other_thread
, &s
);
43 if (future
.wait_for(std::chrono::seconds(1)) != std::future_status::timeout
) {
44 std::cerr
<< "Main: other thread returned too early!\n";
49 std::lock_guard
<std::mutex
> g
{s
.m
};