Fixed design problem: Thread objects can now be created in any context.
Sender thread output queue is now limited. Server thread now terminates correctly. Now cloning packets when sending them to multiple recipients. Fixed one thread issue - GameStart still needs to be made thread safe.
This commit is contained in:
@@ -24,7 +24,6 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define SEND_TIMEOUT_MSEC 50
|
||||
|
||||
SenderThread::SenderThread(SenderCallback &cb)
|
||||
: m_curSocket(INVALID_SOCKET), m_tmpOutBufSize(0), m_callback(cb)
|
||||
@@ -41,7 +40,9 @@ SenderThread::Send(boost::shared_ptr<NetPacket> packet, SOCKET sock)
|
||||
if (packet.get() && IS_VALID_SOCKET(sock))
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_outBufMutex);
|
||||
m_outBuf.push_back(std::make_pair(packet, sock));
|
||||
if (m_outBuf.size() < SEND_QUEUE_SIZE) // Queue is limited in size.
|
||||
m_outBuf.push_back(std::make_pair(packet, sock));
|
||||
// TODO: Throw exception if failed.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user