ftmemsim-valgrind/drd/tests/timed_mutex.cpp
Paul Floyd c2607e093c Bug 446139 DRD/Helgrind with std::shared_timed_mutex::try_lock_until and try_lock_shared_until false positives
also
Bug 446138 DRD/Helgrind with std::timed_mutex::try_lock_until false positives
2021-12-02 00:03:27 +01:00

30 lines
543 B
C++

#include <thread>
#include <iostream>
#include <chrono>
#include <mutex>
#include <cassert>
std::timed_mutex test_mutex;
int global;
void f()
{
auto now=std::chrono::steady_clock::now();
test_mutex.try_lock_until(now + std::chrono::seconds(11));
--global;
test_mutex.unlock();
}
int main()
{
global = 0;
auto now=std::chrono::steady_clock::now();
test_mutex.try_lock_until(now + std::chrono::seconds(11));
++global;
std::thread t(f);
test_mutex.unlock();
t.join();
assert(global == 0);
}