Refactoring
This commit is contained in:
@@ -43,8 +43,8 @@ public:
|
||||
|
||||
private:
|
||||
CSiaApi& _siaApi;
|
||||
|
||||
CSiaDriveConfig* _siaDriveConfig;
|
||||
std::mutex _startStopMutex;
|
||||
|
||||
public:
|
||||
bool IsMounted() const;
|
||||
|
@@ -174,7 +174,6 @@ private:
|
||||
};
|
||||
|
||||
private:
|
||||
static std::mutex _dokanMutex;
|
||||
static CSiaApi* _siaApi;
|
||||
static CSiaDriveConfig* _siaDriveConfig;
|
||||
static std::unique_ptr<CUploadManager> _uploadManager;
|
||||
@@ -1618,11 +1617,6 @@ public:
|
||||
ZeroMemory(&_dokanOptions, sizeof(_dokanOptions));
|
||||
}
|
||||
|
||||
static std::mutex& GetMutex()
|
||||
{
|
||||
return _dokanMutex;
|
||||
}
|
||||
|
||||
static bool IsMounted()
|
||||
{
|
||||
return (_mountThread != nullptr);
|
||||
@@ -1634,7 +1628,6 @@ public:
|
||||
}
|
||||
};
|
||||
// Static member variables
|
||||
std::mutex DokanImpl::_dokanMutex;
|
||||
CSiaApi* DokanImpl::_siaApi = nullptr;
|
||||
CSiaDriveConfig* DokanImpl::_siaDriveConfig = nullptr;
|
||||
std::unique_ptr<CUploadManager> DokanImpl::_uploadManager;
|
||||
@@ -1654,7 +1647,7 @@ CSiaDokanDrive::CSiaDokanDrive(CSiaApi& siaApi, CSiaDriveConfig* siaDriveConfig)
|
||||
_siaApi(siaApi),
|
||||
_siaDriveConfig(siaDriveConfig)
|
||||
{
|
||||
std::lock_guard<std::mutex> l(DokanImpl::GetMutex());
|
||||
std::lock_guard<std::mutex> l(_startStopMutex);
|
||||
if (DokanImpl::IsInitialized())
|
||||
throw SiaDokanDriveException("Sia drive has already been activated");
|
||||
|
||||
@@ -1663,7 +1656,7 @@ CSiaDokanDrive::CSiaDokanDrive(CSiaApi& siaApi, CSiaDriveConfig* siaDriveConfig)
|
||||
|
||||
CSiaDokanDrive::~CSiaDokanDrive()
|
||||
{
|
||||
std::lock_guard<std::mutex> l(DokanImpl::GetMutex());
|
||||
std::lock_guard<std::mutex> l(_startStopMutex);
|
||||
DokanImpl::Shutdown();
|
||||
}
|
||||
|
||||
@@ -1674,17 +1667,17 @@ bool CSiaDokanDrive::IsMounted() const
|
||||
|
||||
void CSiaDokanDrive::Mount(const wchar_t& driveLetter, const SString& cacheLocation, const std::uint64_t& maxCacheSizeBytes)
|
||||
{
|
||||
std::lock_guard<std::mutex> l(DokanImpl::GetMutex());
|
||||
std::lock_guard<std::mutex> l(_startStopMutex);
|
||||
DokanImpl::Mount(driveLetter, cacheLocation);
|
||||
}
|
||||
|
||||
void CSiaDokanDrive::Unmount(const bool& clearCache)
|
||||
{
|
||||
std::lock_guard<std::mutex> l(DokanImpl::GetMutex());
|
||||
std::lock_guard<std::mutex> l(_startStopMutex);
|
||||
DokanImpl::Unmount();
|
||||
}
|
||||
|
||||
void CSiaDokanDrive::ClearCache()
|
||||
{
|
||||
std::lock_guard<std::mutex> l(DokanImpl::GetMutex());
|
||||
std::lock_guard<std::mutex> l(_startStopMutex);
|
||||
}
|
Reference in New Issue
Block a user