diff options
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__ */ |