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:
lotodore
2007-03-20 11:56:30 +00:00
parent 53c4af95c8
commit 804c7eaaa2
12 changed files with 160 additions and 55 deletions
+3 -2
View File
@@ -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.
}
}