diff --git a/platform/cxxsupport/mstd_mutex b/platform/cxxsupport/mstd_mutex index cb3d263..d96cf99 100644 --- a/platform/cxxsupport/mstd_mutex +++ b/platform/cxxsupport/mstd_mutex @@ -46,6 +46,8 @@ #include #include +#include +#include #include "mbed_atomic.h" #include "mbed_assert.h" @@ -105,12 +107,10 @@ unique_lock(mutex_type &m, defer_lock_t) noexcept : pm(&m), owns(false) { } unique_lock(mutex_type &m, try_to_lock_t) : pm(&m), owns(m.try_lock()) { } unique_lock(mutex_type &m, adopt_lock_t) : pm(&m), owns(true) { } -#if 0 // disabled until we have functional mstd::chrono for all toolchains template - unique_lock(mutex_type &m, const chrono::time_point &abs_time) : pm(&m), owns(m.try_lock_until(abs_time)) { } + unique_lock(mutex_type &m, const std::chrono::time_point &abs_time) : pm(&m), owns(m.try_lock_until(abs_time)) { } template - unique_lock(mutex_type &m, const chrono::duration &rel_time) : pm(&m), owns(m.try_lock_for(rel_time)) { } -#endif + unique_lock(mutex_type &m, const std::chrono::duration &rel_time) : pm(&m), owns(m.try_lock_for(rel_time)) { } ~unique_lock() { if (owns) pm->unlock(); } unique_lock(const unique_lock &) = delete; @@ -141,19 +141,17 @@ return owns = pm->try_lock(); } -#if 0 // disabled until we have functional mstd::chrono for all toolchains template - bool try_lock_until(const chrono::time_point &abs_time) { + bool try_lock_until(const std::chrono::time_point &abs_time) { MBED_ASSERT(!owns); return owns = pm->try_lock_until(abs_time); } template - bool try_lock_for(const chrono::duration &rel_time) { + bool try_lock_for(const std::chrono::duration &rel_time) { MBED_ASSERT(!owns); return owns = pm->try_lock_for(rel_time); } -#endif void unlock() { MBED_ASSERT(owns); @@ -313,9 +311,8 @@ // [thread.lock.scoped] // 2+ locks - use std::lock template -class scoped_lock -#if 0 // no definition yet - needs tuple - tuple pm; +class scoped_lock { + mstd::tuple pm; static void ignore(...) { } public: explicit scoped_lock(MutexTypes &... m) : pm(tie(m...)) { mstd::lock(m...); } @@ -324,10 +321,7 @@ scoped_lock(const scoped_lock &) = delete; scoped_lock &operator=(const scoped_lock &) = delete; -} -#else -; -#endif +}; // 0 locks - no-op template <> diff --git a/platform/cxxsupport/mstd_tuple b/platform/cxxsupport/mstd_tuple index e2deafb..d9e926a 100644 --- a/platform/cxxsupport/mstd_tuple +++ b/platform/cxxsupport/mstd_tuple @@ -41,6 +41,10 @@ using std::forward_as_tuple; using std::tie; using std::tuple_cat; +using std::tuple_size; +using std::tuple_element; +using std::tuple_element_t; +using std::get; // [tuple.apply] #if __cpp_lib_apply >= 201603 @@ -84,11 +88,6 @@ } #endif -using std::tuple_size; -using std::tuple_element; -using std::tuple_element_t; -using std::get; - } // namespace mstd #endif // MSTD_TUPLE_