Replace use of ACE threads (#25)
This commit is contained in:
@@ -23,8 +23,8 @@
|
||||
#include "Database/SqlOperations.h"
|
||||
#include "DatabaseEnv.h"
|
||||
|
||||
SqlDelayThread::SqlDelayThread(Database* db, SqlConnection* conn, int workerId)
|
||||
: m_dbEngine(db), m_dbConnection(conn), m_running(true), m_workerId(workerId)
|
||||
SqlDelayThread::SqlDelayThread(Database* db, SqlConnection* conn)
|
||||
: m_dbEngine(db), m_dbConnection(conn), m_running(true)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -35,6 +35,16 @@ SqlDelayThread::~SqlDelayThread()
|
||||
delete m_dbConnection;
|
||||
}
|
||||
|
||||
void SqlDelayThread::addSerialOperation(SqlOperation *op)
|
||||
{
|
||||
m_serialDelayQueue.add(op);
|
||||
}
|
||||
|
||||
bool SqlDelayThread::HasAsyncQuery()
|
||||
{
|
||||
return !m_serialDelayQueue.empty_unsafe();
|
||||
}
|
||||
|
||||
void SqlDelayThread::run()
|
||||
{
|
||||
#ifndef DO_POSTGRESQL
|
||||
@@ -50,7 +60,7 @@ void SqlDelayThread::run()
|
||||
{
|
||||
// if the running state gets turned off while sleeping
|
||||
// empty the queue before exiting
|
||||
ACE_Based::Thread::Sleep(loopSleepms);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(loopSleepms));
|
||||
|
||||
ProcessRequests();
|
||||
|
||||
@@ -83,7 +93,7 @@ void SqlDelayThread::ProcessRequests()
|
||||
}
|
||||
|
||||
// Process any serial operations for this worker
|
||||
while (m_dbEngine->NextSerialDelayedOperation(m_workerId, s))
|
||||
while (m_serialDelayQueue.next(s))
|
||||
{
|
||||
s->Execute(m_dbConnection);
|
||||
delete s;
|
||||
|
||||
Reference in New Issue
Block a user