예제 #1
0
//======================================================================================================================
void SocketWriteThread::run()
{
    Session*            session;


    // Call our internal _startup method
    _startup();

    // Main loop
    while(!mExit)    {

		//if((!this->mServerService) && sessionCount)	{
			//DLOG(info) << "SocketWriteThread::run() START";
			//DLOG(info) << "servicing : " << sessionCount << " Sessions";
			//DLOG(info) << "NO ACTIVE OBJECT";
		//}
		uint32 packetsSend = 0;

        while(mSessionQueue.pop(session))	{
            uint32 packetCount = 0;

            // Process our session
			active_.Send( [=] {
				session->ProcessWriteThread();
				mAsyncSessionQueue.push(session);
			}
			);

        }

		while(mAsyncSessionQueue.pop(session))	{
			_send(session);
		}

		//if((!this->mServerService) && sessionCount)	{
			//DLOG(info) << "SocketWriteThread::run() END";
			//DLOG(info) << "sending : " << packetsSend << "Packets";
		//}

        boost::this_thread::sleep(boost::posix_time::milliseconds(1));
    }

    // Shutdown internally
    _shutdown();
}
예제 #2
0
//======================================================================================================================
void SocketWriteThread::run()
{
    Session*            session;
    Packet*             packet;

    // Call our internal _startup method
    _startup();

    uint32 packets = 50;
    if(mServerService)
        packets = 1000;


    // Main loop
    while(!mExit)
    {

        uint32 sessionCount = mSessionQueue.size();

        for(uint32 i = 0; i < sessionCount; i++)
        {
            uint32 packetCount = 0;
            session = mSessionQueue.pop();

            if(!session)
                continue;

            // Process our session
            session->ProcessWriteThread();

            // Send any outgoing reliable packets
            //uint32 rcount = 0;

            while (session->getOutgoingReliablePacketCount())
            {
                packetCount++;
                if(packetCount > packets)
                    break;

                LOG(INFO) << "Reliable packet sent";
                packet = session->getOutgoingReliablePacket();
                _sendPacket(packet, session);
            }


            packetCount = 0;

            // Send any outgoing unreliable packets
            //uint32 ucount = 0;
            while (session->getOutgoingUnreliablePacketCount())
            {
                LOG(INFO) << "Unreliable packet sent";
                packet = session->getOutgoingUnreliablePacket();
                _sendPacket(packet, session);
                session->DestroyPacket(packet);
            }


            // If the session is still in a connected state, Put us back in the queue.
            if (session->getStatus() != SSTAT_Disconnected)
            {
                mSessionQueue.push(session);
            }
            else
            {
                DLOG(INFO) << "Socket Write Thread: Destroy Session";

                session->setStatus(SSTAT_Destroy);
                mService->AddSessionToProcessQueue(session);
            }
        }


        boost::this_thread::sleep(boost::posix_time::milliseconds(1));
    }

    // Shutdown internally
    _shutdown();
}
예제 #3
0
DatabaseModule_Impl::DatabaseModule_Impl()
:m_pSqliteDB(new CppSQLite3DB())
,m_pSqliteGlobalDB(new CppSQLite3DB())
{
	_startup();
}