2017-09-30 23:51:01 +02:00
|
|
|
#ifndef SAPPHIRE_DBWORKER_H
|
|
|
|
#define SAPPHIRE_DBWORKER_H
|
|
|
|
|
|
|
|
#include <atomic>
|
|
|
|
#include <thread>
|
2017-12-18 14:45:15 +01:00
|
|
|
#include <common/Util/LockedWaitQueue.h>
|
2017-10-07 23:10:13 +02:00
|
|
|
#include <boost/shared_ptr.hpp>
|
2017-09-30 23:51:01 +02:00
|
|
|
|
|
|
|
namespace Core
|
|
|
|
{
|
|
|
|
namespace Db
|
|
|
|
{
|
|
|
|
class DbConnection;
|
|
|
|
class Operation;
|
|
|
|
|
|
|
|
class DbWorker
|
|
|
|
{
|
|
|
|
public:
|
2017-10-07 23:10:13 +02:00
|
|
|
DbWorker( LockedWaitQueue< boost::shared_ptr< Operation > >* newQueue, DbConnection* connection );
|
2017-09-30 23:51:01 +02:00
|
|
|
~DbWorker();
|
|
|
|
|
|
|
|
private:
|
2017-10-07 23:10:13 +02:00
|
|
|
LockedWaitQueue< boost::shared_ptr< Operation > >* m_queue;
|
2017-09-30 23:51:01 +02:00
|
|
|
DbConnection* m_pConn;
|
|
|
|
|
|
|
|
void workerThread();
|
|
|
|
std::thread m_workerThread;
|
|
|
|
|
|
|
|
std::atomic< bool > m_cancelationToken;
|
|
|
|
|
|
|
|
DbWorker( DbWorker const& right ) = delete;
|
|
|
|
DbWorker& operator=( DbWorker const& right ) = delete;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif //SAPPHIRE_DBWORKER_H
|