1
0

Renter settings

This commit is contained in:
Scott E. Graves
2017-03-25 12:25:45 -05:00
parent 77579ffea3
commit e82081fd41
9 changed files with 243 additions and 49 deletions

View File

@@ -41,9 +41,11 @@ private:
HANDLE _stopEvent;
#endif
std::deque<CEventPtr> _eventQueue;
std::deque<std::function<void(const CEvent&)>> _eventConsumers;
std::deque<std::function<void(const CEvent&)>> _eventConsumers;
std::deque<std::function<bool(const CEvent&)>> _oneShotEventConsumers;
std::mutex _eventMutex;
std::unique_ptr<std::thread> _processThread;
std::mutex _oneShotMutex;
public:
static CEventSystem EventSystem;
@@ -52,7 +54,8 @@ private:
void ProcessEvents();
public:
void AddEventConsumer(std::function<void(const CEvent&)> consumer);
void AddEventConsumer(std::function<void(const CEvent&)> consumer);
void AddOneShotEventConsumer(std::function<bool(const CEvent&)> consumer);
void NotifyEvent(CEventPtr eventData);
void Start();
void Stop();

View File

@@ -14,7 +14,7 @@
#include <siaapi.h>
#include <mutex>
#include <eventsystem.h>
NS_BEGIN(Sia)
NS_BEGIN(Api)
NS_BEGIN(Dokan)
@@ -54,5 +54,98 @@ public:
void ClearCache();
};
class SIADRIVE_DOKAN_EXPORTABLE DriveMountEnded :
public CEvent
{
public:
DriveMountEnded(const SString mountLocation, const NTSTATUS& mountStatus) :
_mountLocation(mountLocation),
_mountStatus(mountStatus)
{
}
public:
virtual ~DriveMountEnded()
{
}
private:
const SString _mountLocation;
const NTSTATUS _mountStatus;
public:
virtual std::shared_ptr<CEvent> Clone() const override
{
return std::shared_ptr<CEvent>(new DriveMountEnded(_mountLocation, _mountStatus));
}
virtual SString GetSingleLineMessage() const override
{
return L"DriveMountEnded|LOC|" + _mountLocation + L"|STATUS|" + SString::FromInt32(_mountStatus);
}
};
class SIADRIVE_DOKAN_EXPORTABLE DriveUnMounted :
public CEvent
{
public:
DriveUnMounted(const SString& mountLocation) :
_mountLocation(mountLocation)
{
}
public:
virtual ~DriveUnMounted()
{
}
private:
const SString _mountLocation;
public:
virtual std::shared_ptr<CEvent> Clone() const override
{
return std::shared_ptr<CEvent>(new DriveUnMounted(_mountLocation));
}
virtual SString GetSingleLineMessage() const override
{
return L"DriveUnMounted|LOC|" + _mountLocation;
}
};
class SIADRIVE_DOKAN_EXPORTABLE DriveMounted :
public CEvent
{
public:
DriveMounted(const SString& mountLocation) :
_mountLocation(mountLocation)
{
}
public:
virtual ~DriveMounted()
{
}
private:
const SString _mountLocation;
public:
virtual std::shared_ptr<CEvent> Clone() const override
{
return std::shared_ptr<CEvent>(new DriveMounted(_mountLocation));
}
virtual SString GetSingleLineMessage() const override
{
return L"DriveMounted|LOC|" + _mountLocation;
}
};
NS_END(3)
#endif //_SIADOKANDRIVE_H