From f146ddd307a0ce940ea0e5ebb4a03f56d77480a5 Mon Sep 17 00:00:00 2001 From: Ilusha <63184036+IlyaShurupov@users.noreply.github.com> Date: Wed, 17 Jan 2024 22:42:48 +0300 Subject: [PATCH] Remove mutex class and use std --- Allocators/private/HeapAllocatorGlobal.cpp | 2 +- Allocators/public/HeapAllocatorGlobal.hpp | 4 ++-- CMakeOptions.txt | 2 +- LibraryViewer/private/Player.cpp | 3 +-- Utils/public/Multithreading.hpp | 16 ---------------- 5 files changed, 5 insertions(+), 22 deletions(-) delete mode 100644 Utils/public/Multithreading.hpp diff --git a/Allocators/private/HeapAllocatorGlobal.cpp b/Allocators/private/HeapAllocatorGlobal.cpp index 3687337..7977d2a 100644 --- a/Allocators/private/HeapAllocatorGlobal.cpp +++ b/Allocators/private/HeapAllocatorGlobal.cpp @@ -27,7 +27,7 @@ ualni HeapAllocGlobal::getNAllocations() { return 0; } tp::MemHead* tp::HeapAllocGlobal::mEntry = nullptr; tp::ualni tp::HeapAllocGlobal::mNumAllocations = 0; -tp::Mutex tp::HeapAllocGlobal::mMutex; +std::mutex tp::HeapAllocGlobal::mMutex; bool tp::HeapAllocGlobal::mIgnore = true; // ----------------------- Debug Implementation ---------------------------- // diff --git a/Allocators/public/HeapAllocatorGlobal.hpp b/Allocators/public/HeapAllocatorGlobal.hpp index db91620..86064d6 100644 --- a/Allocators/public/HeapAllocatorGlobal.hpp +++ b/Allocators/public/HeapAllocatorGlobal.hpp @@ -1,7 +1,7 @@ #pragma once #include "Module.hpp" -#include "Multithreading.hpp" +#include namespace tp { @@ -10,7 +10,7 @@ namespace tp { #ifdef MEM_DEBUG static ualni mNumAllocations; static struct MemHead* mEntry; - static Mutex mMutex; + static std::mutex mMutex; static bool mIgnore; #endif diff --git a/CMakeOptions.txt b/CMakeOptions.txt index 49ea8a1..c185d26 100644 --- a/CMakeOptions.txt +++ b/CMakeOptions.txt @@ -1,4 +1,4 @@ -option(MODULES_MEMORY_DEBUG "Debug memory" OFF) +option(MODULES_MEMORY_DEBUG "Debug memory" ON) if (MODULES_MEMORY_DEBUG) add_compile_definitions(MEM_DEBUG) diff --git a/LibraryViewer/private/Player.cpp b/LibraryViewer/private/Player.cpp index 4f693f6..81202bb 100644 --- a/LibraryViewer/private/Player.cpp +++ b/LibraryViewer/private/Player.cpp @@ -1,6 +1,5 @@ #include "Player.hpp" #include "Buffer.hpp" -#include "Multithreading.hpp" #include "portaudio.h" @@ -125,7 +124,7 @@ private: private: bool mInitializationStatus = false; PaStream* mPaStream = nullptr; - tp::Mutex mMutex; + std::mutex mMutex; const tp::halnf* mBuffer = nullptr; const tp::ualni* mPointerMax = nullptr; diff --git a/Utils/public/Multithreading.hpp b/Utils/public/Multithreading.hpp deleted file mode 100644 index 066868b..0000000 --- a/Utils/public/Multithreading.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include - -namespace tp { - class Mutex { - std::mutex mMutex; - - public: - Mutex() = default; - - void lock() { mMutex.lock(); } - - void unlock() { mMutex.unlock(); } - }; -}