Files
TCPlayerbotCore/src/server/database/Database/DatabaseWorker.h
T

51 lines
1.4 KiB
C++
Raw Normal View History

2010-10-07 15:54:07 +02:00
/*
2019-01-01 10:13:49 +01:00
* Copyright (C) 2008-2019 TrinityCore <https://www.trinitycore.org/>
2010-10-07 15:54:07 +02:00
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
2010-08-18 02:25:52 +02:00
*/
#ifndef _WORKERTHREAD_H
#define _WORKERTHREAD_H
2017-05-12 18:49:51 +02:00
#include "Define.h"
#include <atomic>
#include <thread>
2017-05-12 18:49:51 +02:00
template <typename T>
class ProducerConsumerQueue;
2010-08-18 02:25:52 +02:00
class MySQLConnection;
2014-07-01 20:40:56 -05:00
class SQLOperation;
2010-08-18 02:25:52 +02:00
class TC_DATABASE_API DatabaseWorker
2010-08-18 02:25:52 +02:00
{
public:
DatabaseWorker(ProducerConsumerQueue<SQLOperation*>* newQueue, MySQLConnection* connection);
~DatabaseWorker();
2010-08-18 02:25:52 +02:00
private:
ProducerConsumerQueue<SQLOperation*>* _queue;
MySQLConnection* _connection;
void WorkerThread();
std::thread _workerThread;
2017-05-12 18:49:51 +02:00
std::atomic<bool> _cancelationToken;
2014-04-20 16:48:35 +02:00
DatabaseWorker(DatabaseWorker const& right) = delete;
DatabaseWorker& operator=(DatabaseWorker const& right) = delete;
2010-08-18 02:25:52 +02:00
};
#endif