summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsapier <Sapier at GMX dot net>2014-08-22 19:25:21 +0200
committerkwolekr <kwolekr@minetest.net>2014-12-28 23:40:44 -0500
commitacb351950287339b3dcd44e462999e3317047401 (patch)
treeac1d0e4c09610a972d4d2a8f17a767b4a75e5091
parentab55da589c27e65e54956b32a1550e21169447ae (diff)
downloadminetest-acb351950287339b3dcd44e462999e3317047401.tar.gz
minetest-acb351950287339b3dcd44e462999e3317047401.tar.bz2
minetest-acb351950287339b3dcd44e462999e3317047401.zip
Fix MSVC compiler warning about passing this pointer in initializer list
-rw-r--r--src/connection.cpp26
-rw-r--r--src/connection.h16
2 files changed, 28 insertions, 14 deletions
diff --git a/src/connection.cpp b/src/connection.cpp
index cf5be7ed6..a9f1d5457 100644
--- a/src/connection.cpp
+++ b/src/connection.cpp
@@ -1236,10 +1236,9 @@ SharedBuffer<u8> UDPPeer::addSpiltPacket(u8 channel,
/* 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),
@@ -1250,6 +1249,7 @@ ConnectionSendThread::ConnectionSendThread(Connection* parent,
void * ConnectionSendThread::Thread()
{
+ assert(m_connection != NULL);
ThreadStarted();
log_register_thread("ConnectionSend");
@@ -1995,14 +1995,14 @@ void ConnectionSendThread::sendAsPacket(u16 peer_id, u8 channelnum,
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");
@@ -2657,8 +2657,8 @@ Connection::Connection(u32 protocol_id, u32 max_packet_size, float timeout,
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),
@@ -2667,6 +2667,9 @@ Connection::Connection(u32 protocol_id, u32 max_packet_size, float timeout,
{
m_udpSocket.setTimeoutMs(5);
+ m_sendThread.setParent(this);
+ m_receiveThread.setParent(this);
+
m_sendThread.Start();
m_receiveThread.Start();
}
@@ -2678,8 +2681,8 @@ Connection::Connection(u32 protocol_id, u32 max_packet_size, float timeout,
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),
@@ -2689,6 +2692,9 @@ Connection::Connection(u32 protocol_id, u32 max_packet_size, float timeout,
{
m_udpSocket.setTimeoutMs(5);
+ m_sendThread.setParent(this);
+ m_receiveThread.setParent(this);
+
m_sendThread.Start();
m_receiveThread.Start();
diff --git a/src/connection.h b/src/connection.h
index 516702cb8..be1627dfa 100644
--- a/src/connection.h
+++ b/src/connection.h
@@ -918,13 +918,17 @@ class ConnectionSendThread : public JThread {
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; }
@@ -970,11 +974,15 @@ private:
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 ();