diff options
author | Georgios Pinitas <georgios.pinitas@arm.com> | 2019-09-09 17:40:33 +0100 |
---|---|---|
committer | Georgios Pinitas <georgios.pinitas@arm.com> | 2019-09-16 11:45:48 +0000 |
commit | e874ef9b845424dceeac4211ca9dfec24949f03c (patch) | |
tree | 053e1ecedfc3250f70578b7833e5a268f87b0f49 /support/Mutex.h | |
parent | 7470d059a676d217c57c20cf3cd5da5cfbd37c75 (diff) | |
download | ComputeLibrary-e874ef9b845424dceeac4211ca9dfec24949f03c.tar.gz |
COMPMID-2646: Wrap thread-related structure to ease bare-metal support
Wraps "lock_guard" and "unique_lock" to ease bare-metal support.
Adds basic armclang compilation flow.
Change-Id: I44ccd042652acd6a9b442c57c879db3891abb0e2
Signed-off-by: Georgios Pinitas <georgios.pinitas@arm.com>
Reviewed-on: https://review.mlplatform.org/c/1923
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Pablo Marquez <pablo.tello@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'support/Mutex.h')
-rw-r--r-- | support/Mutex.h | 66 |
1 files changed, 65 insertions, 1 deletions
diff --git a/support/Mutex.h b/support/Mutex.h index d70dd7595b..c398c570af 100644 --- a/support/Mutex.h +++ b/support/Mutex.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 ARM Limited. + * Copyright (c) 2017-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -31,6 +31,14 @@ namespace arm_compute #ifndef NO_MULTI_THREADING /** Wrapper of Mutex data-object */ using Mutex = std::mutex; + +/** Wrapper of lock_guard data-object */ +template <typename Mutex> +using lock_guard = std::lock_guard<Mutex>; + +/** Wrapper of lock_guard data-object */ +template <typename Mutex> +using unique_lock = std::unique_lock<Mutex>; #else /* NO_MULTI_THREADING */ /** Wrapper implementation of Mutex data-object */ class Mutex @@ -56,6 +64,62 @@ public: return true; } }; + +/** Wrapper implementation of lock-guard data-object */ +template <typename Mutex> +class lock_guard +{ +public: + typedef Mutex mutex_type; + +public: + explicit lock_guard(Mutex &m_) + : m(m_) + { + } + ~lock_guard() + { + } + lock_guard(const lock_guard &) = delete; + +private: + mutex_type &m; +}; + +/** Wrapper implementation of unique-lock data-object */ +template <typename Mutex> +class unique_lock +{ +public: + typedef Mutex mutex_type; + +public: + unique_lock() noexcept : m(nullptr) + { + } + explicit unique_lock(mutex_type &m) + : m(&m) + { + } + unique_lock(const unique_lock &) = delete; + unique_lock(unique_lock &&) = default; + unique_lock &operator=(const unique_lock &) = delete; + unique_lock &operator=(unique_lock &&) = default; + ~unique_lock() = default; + void lock() + { + } + bool try_lock() + { + return true; + } + void unlock() + { + } + +private: + mutex_type *m; +}; #endif /* NO_MULTI_THREADING */ } #endif /* __ARM_COMPUTE_MUTEX_H__ */ |