From 76a655aa6c8aae397c4db6d4ce68b7d64618dd08 Mon Sep 17 00:00:00 2001 From: Andrey Astafyev Date: Mon, 6 Apr 2020 00:06:57 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8F=20=D0=B2=20cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/myx/filesystem/paths.cpp | 17 +++++++++++++++++ src/myx/filesystem/paths.hpp | 17 +---------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/myx/filesystem/paths.cpp b/src/myx/filesystem/paths.cpp index 3e131bb..9920e2d 100644 --- a/src/myx/filesystem/paths.cpp +++ b/src/myx/filesystem/paths.cpp @@ -13,6 +13,23 @@ namespace filesystem { Paths::Paths() = default; +Paths* Paths::getInstance() +{ + volatile Paths* localInstance = mInstance.load( std::memory_order_acquire ); + if ( !localInstance ) + { + std::lock_guard< std::mutex > myLock( mMutex ); + localInstance = mInstance.load( std::memory_order_relaxed ); + if ( !localInstance ) // -V1036 + { + localInstance = new Paths(); + mInstance.store( const_cast< Paths* >( localInstance ), std::memory_order_release ); + } + } + return( const_cast< Paths* >( localInstance ) ); +} + + Paths::HierarchyType Paths::getHierarchyType() { QRegExp binRegexp( "/s*bin$" ); diff --git a/src/myx/filesystem/paths.hpp b/src/myx/filesystem/paths.hpp index 3eaa4c6..0f7a008 100644 --- a/src/myx/filesystem/paths.hpp +++ b/src/myx/filesystem/paths.hpp @@ -91,22 +91,7 @@ public: * @brief getInstance * @return Уникальный экземпляр класса Paths */ - static Paths* getInstance() - { - volatile Paths* localInstance = mInstance.load( std::memory_order_acquire ); - if ( !localInstance ) - { - std::lock_guard< std::mutex > myLock( mMutex ); - localInstance = mInstance.load( std::memory_order_relaxed ); - if ( !localInstance ) // -V1036 - { - localInstance = new Paths(); - mInstance.store( const_cast< Paths* >( localInstance ), std::memory_order_release ); - } - } - return( const_cast< Paths* >( localInstance ) ); - } - + static Paths* getInstance(); /** * @brief Обновление путей с учётом расположения исполняемого файла