コード例 #1
0
ファイル: SqlDelayThread.cpp プロジェクト: 1ATOM/mangos
void SqlDelayThread::run()
{
    #ifndef DO_POSTGRESQL
    mysql_thread_init();
    #endif

    const uint32 loopSleepms = 10;

    const uint32 pingEveryLoop = m_dbEngine->GetPingIntervall()/loopSleepms;

    uint32 loopCounter = 0;
    while (m_running)
    {
        // if the running state gets turned off while sleeping
        // empty the queue before exiting

        ACE_Based::Thread::Sleep(loopSleepms);
        SqlOperation* s;
        while (m_sqlQueue.next(s))
        {
            s->Execute(m_dbEngine);
            delete s;
        }
        if((loopCounter++) >= pingEveryLoop)
        {
            loopCounter = 0;
            delete m_dbEngine->Query("SELECT 1");
        }
    }

    #ifndef DO_POSTGRESQL
    mysql_thread_end();
    #endif
}
コード例 #2
0
ファイル: SqlDelayThread.cpp プロジェクト: Bootz/TC-One
void SqlDelayThread::run()
{
    SqlOperation* s;
    #ifndef DO_POSTGRESQL
    mysql_thread_init();
    #endif

    while (m_running)
    {
      try
	{
	  s = m_sqlQueue.next();
	}
      catch(...)
	{continue;}
      if(!s)
	continue;
      s->Execute(m_dbEngine);
      delete s;
    }

    #ifndef DO_POSTGRESQL
    mysql_thread_end();
    #endif
}
コード例 #3
0
void SqlDelayThread::ProcessRequests()
{
    SqlOperation* s = NULL;
    while (m_sqlQueue.next(s))
    {
        s->Execute(m_dbConnection);
        delete s;
    }
}
コード例 #4
0
ファイル: SqlOperations.cpp プロジェクト: Blumfield/ptc2
bool SqlTransaction::Execute(SqlConnection *conn)
{
    if (m_queue.empty())
        return true;

    LOCK_DB_CONN(conn);

    conn->BeginTransaction();

    const int nItems = m_queue.size();
    for (int i = 0; i < nItems; ++i)
    {
        SqlOperation * pStmt = m_queue[i];
        if(!pStmt->Execute(conn))
        {
            conn->RollbackTransaction();
            return false;
        }
    }

    return conn->CommitTransaction();
}
コード例 #5
0
ファイル: SqlDelayThread.cpp プロジェクト: executor/riboncore
void SqlDelayThread::run()
{
    #ifndef DO_POSTGRESQL
    mysql_thread_init();
    #endif

    while (m_running)
    {
        // if the running state gets turned off while sleeping
        // empty the queue before exiting
        ACE_Based::Thread::Sleep(10);
        SqlOperation* s;
        while (m_sqlQueue.next(s))
        {
            s->Execute(m_dbEngine);
            delete s;
        }
    }

    #ifndef DO_POSTGRESQL
    mysql_thread_end();
    #endif
}