coregrind/m_gdbserver/remote-utils.c (prepare_resume_reply): Use memcpy
[valgrind.git] / drd / tests / timed_mutex.cpp
blobfa7464ea5b1e53ba0a3f3dfd2b6926ea0d87e30f
1 #include <thread>
2 #include <iostream>
3 #include <chrono>
4 #include <mutex>
5 #include <cassert>
7 std::timed_mutex test_mutex;
8 int global;
10 void f()
12 auto now=std::chrono::steady_clock::now();
13 test_mutex.try_lock_until(now + std::chrono::seconds(11));
14 --global;
15 std::this_thread::sleep_for(std::chrono::seconds(1));
16 test_mutex.unlock();
20 int main()
22 global = 0;
23 std::thread t(f);
24 std::this_thread::sleep_for(std::chrono::seconds(1));
25 auto now=std::chrono::steady_clock::now();
26 test_mutex.try_lock_until(now + std::chrono::seconds(11));
27 ++global;
28 test_mutex.unlock();
29 t.join();
30 assert(global == 0);