From 59d3e7ed5af1c1ebd58f0b9e887e02671f801403 Mon Sep 17 00:00:00 2001 From: GeorgH93 Date: Sun, 4 Apr 2021 22:28:43 +0200 Subject: [PATCH] Minor improvements --- openVulkanoCpp/Base/MutexProtectedObject.hpp | 63 -------------------- openVulkanoCpp/Data/Containers/Array.hpp | 4 +- 2 files changed, 2 insertions(+), 65 deletions(-) delete mode 100644 openVulkanoCpp/Base/MutexProtectedObject.hpp diff --git a/openVulkanoCpp/Base/MutexProtectedObject.hpp b/openVulkanoCpp/Base/MutexProtectedObject.hpp deleted file mode 100644 index c6561fa..0000000 --- a/openVulkanoCpp/Base/MutexProtectedObject.hpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -#pragma once - -#include - -namespace openVulkanoCpp -{ - template - class MutexProtectedObject - { - T object; - std::mutex mutex; - - public: - class Accessor - { - std::unique_lock lock; - T& ref; - - public: - Accessor(std::mutex& m, T& obj) - : lock(m), ref(obj) - {} - - T* operator->() { return &ref; } - - T& Get() { return ref; } - }; - - MutexProtectedObject() = default; - - MutexProtectedObject(const T& initValue) : object(initValue) {} - - template - MutexProtectedObject(Args&&... args) - : object(std::forward(args)...) - {} - - MutexProtectedObject(const MutexProtectedObject&) = delete; - - Accessor Access() - { - return Accessor(mutex, object); - } - - MutexProtectedObject& operator =(const T& value) - { - Accessor accessor = Access(); - object = value; - } - - operator T() - { - Accessor accessor = Access(); - return accessor.Get(); - } - }; -} diff --git a/openVulkanoCpp/Data/Containers/Array.hpp b/openVulkanoCpp/Data/Containers/Array.hpp index 066840d..ef2d7e9 100644 --- a/openVulkanoCpp/Data/Containers/Array.hpp +++ b/openVulkanoCpp/Data/Containers/Array.hpp @@ -92,12 +92,12 @@ namespace openVulkanoCpp return *this; } - T& operator[](size_t n) noexcept + T& operator[](size_t n) { return data[n]; } - const T& operator[](size_t n) const noexcept + const T& operator[](size_t n) const { return data[n]; }