[7810] Moved ZThread related code on ACE framework.

Remove ZThread source code from mangos.
Signed-off-by: AlexDereka <dereka.alex@gmail.com>
This commit is contained in:
Ambal 2009-05-11 12:13:41 +04:00 committed by AlexDereka
parent f117ce3420
commit 2aff48cc5d
182 changed files with 684 additions and 21041 deletions

View file

@ -21,7 +21,7 @@
#include "Util.h"
#include "Policies/SingletonImp.h"
#include "Platform/Define.h"
#include "../src/zthread/ThreadImpl.h"
#include "Threading.h"
#include "DatabaseEnv.h"
#include "Database/PGSQLDelayThread.h"
#include "Database/SqlOperations.h"
@ -124,7 +124,7 @@ QueryResult* DatabasePostgre::Query(const char *sql)
uint32 fieldCount = 0;
// guarded block for thread-safe request
ZThread::Guard<ZThread::FastMutex> query_connection_guard(mMutex);
ACE_Guard<ACE_Thread_Mutex> query_connection_guard(mMutex);
#ifdef MANGOS_DEBUG
uint32 _s = getMSTime();
#endif
@ -172,9 +172,10 @@ bool DatabasePostgre::Execute(const char *sql)
return false;
// don't use queued execution if it has not been initialized
if (!m_threadBody) return DirectExecute(sql);
if (!m_threadBody)
return DirectExecute(sql);
tranThread = ZThread::ThreadImpl::current(); // owner of this transaction
tranThread = ACE_Based::Thread::current(); // owner of this transaction
TransactionQueues::iterator i = m_tranQueues.find(tranThread);
if (i != m_tranQueues.end() && i->second != NULL)
{ // Statement for transaction
@ -195,7 +196,7 @@ bool DatabasePostgre::DirectExecute(const char* sql)
return false;
{
// guarded block for thread-safe request
ZThread::Guard<ZThread::FastMutex> query_connection_guard(mMutex);
ACE_Guard<ACE_Thread_Mutex> query_connection_guard(mMutex);
#ifdef MANGOS_DEBUG
uint32 _s = getMSTime();
#endif
@ -245,7 +246,7 @@ bool DatabasePostgre::BeginTransaction()
// don't use queued execution if it has not been initialized
if (!m_threadBody)
{
if (tranThread==ZThread::ThreadImpl::current())
if (tranThread == ACE_Based::Thread::current())
return false; // huh? this thread already started transaction
mMutex.acquire();
if (!_TransactionCmd("START TRANSACTION"))
@ -256,7 +257,7 @@ bool DatabasePostgre::BeginTransaction()
return true;
}
// transaction started
tranThread = ZThread::ThreadImpl::current(); // owner of this transaction
tranThread = ACE_Based::Thread::current(); // owner of this transaction
TransactionQueues::iterator i = m_tranQueues.find(tranThread);
if (i != m_tranQueues.end() && i->second != NULL)
// If for thread exists queue and also contains transaction
@ -276,14 +277,14 @@ bool DatabasePostgre::CommitTransaction()
// don't use queued execution if it has not been initialized
if (!m_threadBody)
{
if (tranThread!=ZThread::ThreadImpl::current())
if (tranThread != ACE_Based::Thread::current())
return false;
bool _res = _TransactionCmd("COMMIT");
tranThread = NULL;
mMutex.release();
return _res;
}
tranThread = ZThread::ThreadImpl::current();
tranThread = ACE_Based::Thread::current();
TransactionQueues::iterator i = m_tranQueues.find(tranThread);
if (i != m_tranQueues.end() && i->second != NULL)
{
@ -302,14 +303,14 @@ bool DatabasePostgre::RollbackTransaction()
// don't use queued execution if it has not been initialized
if (!m_threadBody)
{
if (tranThread!=ZThread::ThreadImpl::current())
if (tranThread != ACE_Based::Thread::current())
return false;
bool _res = _TransactionCmd("ROLLBACK");
tranThread = NULL;
mMutex.release();
return _res;
}
tranThread = ZThread::ThreadImpl::current();
tranThread = ACE_Based::Thread::current();
TransactionQueues::iterator i = m_tranQueues.find(tranThread);
if (i != m_tranQueues.end() && i->second != NULL)
{
@ -332,7 +333,8 @@ void DatabasePostgre::InitDelayThread()
assert(!m_delayThread);
//New delay thread for delay execute
m_delayThread = new ZThread::Thread(m_threadBody = new PGSQLDelayThread(this));
m_threadBody = new PGSQLDelayThread(this);
m_delayThread = new ACE_Based::Thread(*m_threadBody);
}
void DatabasePostgre::HaltDelayThread()