4646
4747#include <mstd_utility>
4848#include <mstd_functional>
49+ #include <mstd_tuple>
50+ #include <chrono>
4951
5052#include "mbed_atomic.h"
5153#include "mbed_assert.h"
@@ -105,12 +107,10 @@ public:
105107 unique_lock(mutex_type &m, defer_lock_t) noexcept : pm(&m), owns(false) { }
106108 unique_lock(mutex_type &m, try_to_lock_t) : pm(&m), owns(m.try_lock()) { }
107109 unique_lock(mutex_type &m, adopt_lock_t) : pm(&m), owns(true) { }
108- #if 0 // disabled until we have functional mstd::chrono for all toolchains
109110 template <class Clock, class Duration>
110- unique_lock(mutex_type &m, const chrono::time_point<Clock, Duration> &abs_time) : pm(&m), owns(m.try_lock_until(abs_time)) { }
111+ unique_lock(mutex_type &m, const std:: chrono::time_point<Clock, Duration> &abs_time) : pm(&m), owns(m.try_lock_until(abs_time)) { }
111112 template <class Rep, class Period>
112- unique_lock(mutex_type &m, const chrono::duration<Rep, Period> &rel_time) : pm(&m), owns(m.try_lock_for(rel_time)) { }
113- #endif
113+ unique_lock(mutex_type &m, const std::chrono::duration<Rep, Period> &rel_time) : pm(&m), owns(m.try_lock_for(rel_time)) { }
114114 ~unique_lock() { if (owns) pm->unlock(); }
115115
116116 unique_lock(const unique_lock &) = delete;
@@ -141,19 +141,17 @@ public:
141141 return owns = pm->try_lock();
142142 }
143143
144- #if 0 // disabled until we have functional mstd::chrono for all toolchains
145144 template <class Clock, class Duration>
146- bool try_lock_until(const chrono::time_point<Clock, Duration> &abs_time) {
145+ bool try_lock_until(const std:: chrono::time_point<Clock, Duration> &abs_time) {
147146 MBED_ASSERT(!owns);
148147 return owns = pm->try_lock_until(abs_time);
149148 }
150149
151150 template <class Rep, class Period>
152- bool try_lock_for(const chrono::duration<Rep, Period> &rel_time) {
151+ bool try_lock_for(const std:: chrono::duration<Rep, Period> &rel_time) {
153152 MBED_ASSERT(!owns);
154153 return owns = pm->try_lock_for(rel_time);
155154 }
156- #endif
157155
158156 void unlock() {
159157 MBED_ASSERT(owns);
@@ -313,9 +311,8 @@ using std::scoped_lock;
313311// [thread.lock.scoped]
314312// 2+ locks - use std::lock
315313template <class... MutexTypes>
316- class scoped_lock
317- #if 0 // no definition yet - needs tuple
318- tuple<MutexTypes &...> pm;
314+ class scoped_lock {
315+ mstd::tuple<MutexTypes &...> pm;
319316 static void ignore(...) { }
320317public:
321318 explicit scoped_lock(MutexTypes &... m) : pm(tie(m...)) { mstd::lock(m...); }
@@ -324,10 +321,7 @@ public:
324321
325322 scoped_lock(const scoped_lock &) = delete;
326323 scoped_lock &operator=(const scoped_lock &) = delete;
327- }
328- #else
329- ;
330- #endif
324+ };
331325
332326// 0 locks - no-op
333327template <>
0 commit comments