aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-05-11 11:50:49 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-05-11 11:50:49 +0200
commit6ebefaae2072d70c2ca733402545fcc7775ad978 (patch)
tree7cd89a896f2139622c3bbb93ed8df4118394df9a
parent30c675400f56e6d4636e8f8f2b347655581613da (diff)
Minor tweaks to own C++14 threads implementation on MinGW
-rw-r--r--libbutl/mingw-condition_variable.hxx8
-rw-r--r--libbutl/mingw-mutex.hxx5
2 files changed, 8 insertions, 5 deletions
diff --git a/libbutl/mingw-condition_variable.hxx b/libbutl/mingw-condition_variable.hxx
index ce94941..965f533 100644
--- a/libbutl/mingw-condition_variable.hxx
+++ b/libbutl/mingw-condition_variable.hxx
@@ -126,9 +126,17 @@ public:
const std::chrono::duration<Rep, Period>& rel_time,
Predicate pred)
{
+#if __cplusplus >= 201703L
+ using steady_duration = typename std::chrono::steady_clock::duration;
+ return wait_until(lock,
+ std::chrono::steady_clock::now() +
+ std::chrono::ceil<steady_duration> (rel_time),
+ std::move(pred));
+#else
return wait_until(lock,
std::chrono::steady_clock::now() + rel_time,
std::move(pred));
+#endif
}
template <class Clock, class Duration>
cv_status wait_until (unique_lock<mutex>& lock,
diff --git a/libbutl/mingw-mutex.hxx b/libbutl/mingw-mutex.hxx
index 375a572..d297786 100644
--- a/libbutl/mingw-mutex.hxx
+++ b/libbutl/mingw-mutex.hxx
@@ -81,11 +81,6 @@ namespace mingw_stdthread
// Slim Reader-Writer (SRW)-based implementation that requires Windows 7.
//
-#if !defined(SRWLOCK_INIT)
-#error SRWLOCK_INIT macro is not defined
-//#define SRWLOCK_INIT {0}
-#endif
-
class mutex
{
protected: