1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-01 16:37:45 +00:00
sapphire/src/common/Database/DbWorker.h

38 lines
710 B
C
Raw Normal View History

#ifndef SAPPHIRE_DBWORKER_H
#define SAPPHIRE_DBWORKER_H
#include <atomic>
#include <thread>
2018-03-06 22:22:19 +01:00
#include "Util/LockedWaitQueue.h"
2018-10-24 12:53:26 +02:00
#include <memory>
2018-10-28 21:53:21 +01:00
namespace Core::Db
{
2018-10-28 21:53:21 +01:00
class DbConnection;
class Operation;
2018-10-28 21:53:21 +01:00
class DbWorker
{
public:
DbWorker( LockedWaitQueue< std::shared_ptr< Operation > >* newQueue, DbConnection* connection );
2018-10-28 21:53:21 +01:00
~DbWorker();
2018-10-28 21:53:21 +01:00
private:
LockedWaitQueue< std::shared_ptr< Operation > >* m_queue;
DbConnection* m_pConn;
2018-10-28 21:53:21 +01:00
void workerThread();
2018-10-28 21:53:21 +01:00
std::thread m_workerThread;
2018-10-28 21:53:21 +01:00
std::atomic< bool > m_cancelationToken;
2018-10-28 21:53:21 +01:00
DbWorker( DbWorker const& right ) = delete;
2018-10-28 21:53:21 +01:00
DbWorker& operator=( DbWorker const& right ) = delete;
};
}
#endif //SAPPHIRE_DBWORKER_H