/* Connection Threads */
/******************************************************************************/
-ConnectionSendThread::ConnectionSendThread(Connection* parent,
- unsigned int max_packet_size,
+ConnectionSendThread::ConnectionSendThread( unsigned int max_packet_size,
float timeout) :
- m_connection(parent),
+ m_connection(NULL),
m_max_packet_size(max_packet_size),
m_timeout(timeout),
m_max_commands_per_iteration(1),
void * ConnectionSendThread::Thread()
{
+ assert(m_connection != NULL);
ThreadStarted();
log_register_thread("ConnectionSend");
m_outgoing_queue.push_back(packet);
}
-ConnectionReceiveThread::ConnectionReceiveThread(Connection* parent,
- unsigned int max_packet_size) :
- m_connection(parent)
+ConnectionReceiveThread::ConnectionReceiveThread(unsigned int max_packet_size) :
+ m_connection(NULL)
{
}
void * ConnectionReceiveThread::Thread()
{
+ assert(m_connection != NULL);
ThreadStarted();
log_register_thread("ConnectionReceive");
m_event_queue(),
m_peer_id(0),
m_protocol_id(protocol_id),
- m_sendThread(this, max_packet_size, timeout),
- m_receiveThread(this, max_packet_size),
+ m_sendThread(max_packet_size, timeout),
+ m_receiveThread(max_packet_size),
m_info_mutex(),
m_bc_peerhandler(0),
m_bc_receive_timeout(0),
{
m_udpSocket.setTimeoutMs(5);
+ m_sendThread.setParent(this);
+ m_receiveThread.setParent(this);
+
m_sendThread.Start();
m_receiveThread.Start();
}
m_event_queue(),
m_peer_id(0),
m_protocol_id(protocol_id),
- m_sendThread(this, max_packet_size, timeout),
- m_receiveThread(this, max_packet_size),
+ m_sendThread(max_packet_size, timeout),
+ m_receiveThread(max_packet_size),
m_info_mutex(),
m_bc_peerhandler(peerhandler),
m_bc_receive_timeout(0),
{
m_udpSocket.setTimeoutMs(5);
+ m_sendThread.setParent(this);
+ m_receiveThread.setParent(this);
+
m_sendThread.Start();
m_receiveThread.Start();
public:
friend class UDPPeer;
- ConnectionSendThread(Connection* parent,
- unsigned int max_packet_size, float timeout);
+ ConnectionSendThread(unsigned int max_packet_size, float timeout);
void * Thread ();
void Trigger();
+ void setParent(Connection* parent) {
+ assert(parent != NULL);
+ m_connection = parent;
+ }
+
void setPeerTimeout(float peer_timeout)
{ m_timeout = peer_timeout; }
class ConnectionReceiveThread : public JThread {
public:
- ConnectionReceiveThread(Connection* parent,
- unsigned int max_packet_size);
+ ConnectionReceiveThread(unsigned int max_packet_size);
void * Thread ();
+ void setParent(Connection* parent) {
+ assert(parent != NULL);
+ m_connection = parent;
+ }
+
private:
void receive ();