diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2020-02-13 20:13:37 -0500 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2020-02-18 17:25:03 -0500 |
| commit | 29244f3328cdf878ac557acbbabb19a5b7190b2d (patch) | |
| tree | cb9ad7bdf07f258fe47cee33ef31a49f989f5078 /src/shared/directoryentry.h | |
| parent | d082a91ad617808a6dd89ad9fdb9479524795520 (diff) | |
thread-safe directory entry
Diffstat (limited to 'src/shared/directoryentry.h')
| -rw-r--r-- | src/shared/directoryentry.h | 8 |
1 files changed, 8 insertions, 0 deletions
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 <http://www.gnu.org/licenses/>. #include <vector>
#include <map>
#include <cassert>
+#include <mutex>
+
#define WIN32_MEAN_AND_LEAN
#include <Windows.h>
#include <bsatk.h>
@@ -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<FileRegister> m_FileRegister;
boost::weak_ptr<OriginConnection> 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<FileEntry::Index, FileEntry::Ptr> m_Files;
boost::shared_ptr<OriginConnection> m_OriginConnection;
@@ -545,6 +551,8 @@ private: std::set<int> m_Origins;
bool m_Populated;
bool m_TopLevel;
+ std::mutex m_SubDirMutex;
+ std::mutex m_FilesMutex;
DirectoryEntry(const DirectoryEntry &reference);
|
