From 973fdce79b191b5c2887a0e410979be84ae995f4 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 21 Jul 2018 14:51:37 -0400 Subject: [PATCH] common: Remove synchronized_wrapper.h This is entirely unused in the codebase. --- src/common/CMakeLists.txt | 1 - src/common/synchronized_wrapper.h | 85 ------------------------------- 2 files changed, 86 deletions(-) delete mode 100644 src/common/synchronized_wrapper.h diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index f49a316127..d5d4f6f827 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -63,7 +63,6 @@ add_library(common STATIC string_util.cpp string_util.h swap.h - synchronized_wrapper.h telemetry.cpp telemetry.h thread.cpp diff --git a/src/common/synchronized_wrapper.h b/src/common/synchronized_wrapper.h deleted file mode 100644 index 4a1984c46e..0000000000 --- a/src/common/synchronized_wrapper.h +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2015 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#pragma once - -#include -#include - -namespace Common { - -template -class SynchronizedWrapper; - -/** - * Synchronized reference, that keeps a SynchronizedWrapper's mutex locked during its lifetime. This - * greatly reduces the chance that someone will access the wrapped resource without locking the - * mutex. - */ -template -class SynchronizedRef { -public: - SynchronizedRef(SynchronizedWrapper& wrapper) : wrapper(&wrapper) { - wrapper.mutex.lock(); - } - - SynchronizedRef(SynchronizedRef&) = delete; - SynchronizedRef(SynchronizedRef&& o) : wrapper(o.wrapper) { - o.wrapper = nullptr; - } - - ~SynchronizedRef() { - if (wrapper) - wrapper->mutex.unlock(); - } - - SynchronizedRef& operator=(SynchronizedRef&) = delete; - SynchronizedRef& operator=(SynchronizedRef&& o) { - std::swap(wrapper, o.wrapper); - return *this; - } - - T& operator*() { - return wrapper->data; - } - const T& operator*() const { - return wrapper->data; - } - - T* operator->() { - return &wrapper->data; - } - const T* operator->() const { - return &wrapper->data; - } - -private: - SynchronizedWrapper* wrapper; -}; - -/** - * Wraps an object, only allowing access to it via a locking reference wrapper. Good to ensure no - * one forgets to lock a mutex before acessing an object. To access the wrapped object construct a - * SyncronizedRef on this wrapper. Inspired by Rust's Mutex type - * (http://doc.rust-lang.org/std/sync/struct.Mutex.html). - */ -template -class SynchronizedWrapper { -public: - template - SynchronizedWrapper(Args&&... args) : data(std::forward(args)...) {} - - SynchronizedRef Lock() { - return {*this}; - } - -private: - template - friend class SynchronizedRef; - - std::mutex mutex; - T data; -}; - -} // namespace Common