From 29244f3328cdf878ac557acbbabb19a5b7190b2d Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Thu, 13 Feb 2020 20:13:37 -0500 Subject: thread-safe directory entry --- src/shared/directoryentry.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/shared/directoryentry.h') diff --git a/src/shared/directoryentry.h b/src/shared/directoryentry.h index c8ec8a4e..71e8b32c 100644 --- a/src/shared/directoryentry.h +++ b/src/shared/directoryentry.h @@ -26,6 +26,8 @@ along with Mod Organizer. If not, see . #include #include #include +#include + #define WIN32_MEAN_AND_LEAN #include #include @@ -274,6 +276,7 @@ public: void addFile(FileEntry::Index index) { + std::scoped_lock lock(m_Mutex); m_Files.insert(index); } @@ -290,6 +293,7 @@ private: int m_Priority; boost::weak_ptr m_FileRegister; boost::weak_ptr m_OriginConnection; + mutable std::mutex m_Mutex; FilesOrigin( int ID, const std::wstring &name, const std::wstring &path, int priority, @@ -313,6 +317,7 @@ public: size_t size() const { + std::scoped_lock lock(m_Mutex); return m_Files.size(); } @@ -323,6 +328,7 @@ public: void sortOrigins(); private: + mutable std::mutex m_Mutex; std::map m_Files; boost::shared_ptr m_OriginConnection; @@ -545,6 +551,8 @@ private: std::set m_Origins; bool m_Populated; bool m_TopLevel; + std::mutex m_SubDirMutex; + std::mutex m_FilesMutex; DirectoryEntry(const DirectoryEntry &reference); -- cgit v1.3.1