41 lines
1014 B
C++
41 lines
1014 B
C++
#ifndef _AUTOTHREAD_H
|
|
#define _AUTOTHREAD_H
|
|
|
|
#include <siacommon.h>
|
|
|
|
NS_BEGIN(Sia)
|
|
NS_BEGIN(Api)
|
|
|
|
class CSiaDriveConfig;
|
|
class CSiaCurl;
|
|
class SIADRIVE_EXPORTABLE CAutoThread
|
|
{
|
|
public:
|
|
CAutoThread(const CSiaCurl& siaCurl, CSiaDriveConfig* siaDriveConfig);
|
|
CAutoThread(const CSiaCurl& siaCurl, CSiaDriveConfig* siaDriveConfig, std::function<void(const CSiaCurl&, CSiaDriveConfig*)> autoThreadCallback);
|
|
|
|
public:
|
|
virtual ~CAutoThread();
|
|
|
|
private:
|
|
bool _stopRequested;
|
|
std::unique_ptr<CSiaCurl> _siaCurl;
|
|
CSiaDriveConfig* _siaDriveConfig;
|
|
std::function<void(const CSiaCurl&, CSiaDriveConfig*)> _AutoThreadCallback;
|
|
std::unique_ptr<std::thread> _thread;
|
|
std::mutex _startStopMutex;
|
|
std::mutex _stopMutex;
|
|
std::condition_variable _stopEvent;
|
|
|
|
protected:
|
|
virtual void AutoThreadCallback(const CSiaCurl& siaCurl, CSiaDriveConfig* siaDriveConfig);
|
|
|
|
public:
|
|
bool IsRunning() const;
|
|
SiaHostConfig GetHostConfig() const;
|
|
void StartAutoThread();
|
|
void StopAutoThread();
|
|
};
|
|
|
|
NS_END(2)
|
|
#endif //_AUTOTHREAD_H
|