class Connection: needless functions removed; count replaced with sum for debugging purpose.

This commit is contained in:
Roland Jax
2014-11-11 21:26:42 +01:00
parent 70ea02b143
commit 2695dd141d
3 changed files with 9 additions and 11 deletions
+4 -4
View File
@@ -23,7 +23,7 @@
extern LogInstance& L; extern LogInstance& L;
int Connection::m_count = -1; int Connection::m_sum = 0;
void Connection::addResult(Message message) void Connection::addResult(Message message)
{ {
@@ -85,10 +85,10 @@ void* Connection::run()
m_data->add(new Message(data, this)); m_data->add(new Message(data, this));
// wait for result // wait for result
L.log(net, debug, "[%08x] wait for result", getID()); L.log(net, debug, "[%05d] wait for result", getID());
Message* message = m_result.remove(); Message* message = m_result.remove();
L.log(net, debug, "[%08x] result added", getID()); L.log(net, debug, "[%05d] result added", getID());
std::string result(message->getData()); std::string result(message->getData());
if (m_socket->isValid() == true) if (m_socket->isValid() == true)
@@ -104,7 +104,7 @@ void* Connection::run()
delete m_socket; delete m_socket;
m_running = false; m_running = false;
L.log(net, trace, "[%08x] connection closed", getID()); L.log(net, trace, "[%05d] connection closed", getID());
return NULL; return NULL;
} }
+4 -6
View File
@@ -31,9 +31,7 @@ class Connection : public Thread
public: public:
Connection(TCPSocket* socket, WQueue<Message*>* data) Connection(TCPSocket* socket, WQueue<Message*>* data)
: m_socket(socket), m_data(data), m_running(false) { m_count++; } : m_socket(socket), m_data(data), m_running(false) { m_sum++; m_id = m_sum;}
~Connection() { m_count--; }
void addResult(Message message); void addResult(Message message);
@@ -41,8 +39,7 @@ public:
void stop() const { m_notify.notify(); } void stop() const { m_notify.notify(); }
bool isRunning() const { return m_running; } bool isRunning() const { return m_running; }
pthread_t getID() { return this->self(); } int getID() { return m_id; }
int numConnections() const { return m_count; }
private: private:
TCPSocket* m_socket; TCPSocket* m_socket;
@@ -50,8 +47,9 @@ private:
WQueue<Message*> m_result; WQueue<Message*> m_result;
Notify m_notify; Notify m_notify;
bool m_running; bool m_running;
int m_id;
static int m_count; static int m_sum;
}; };
+1 -1
View File
@@ -107,7 +107,7 @@ void* Network::run()
connection->start("connection"); connection->start("connection");
m_connections.push_back(connection); m_connections.push_back(connection);
L.log(net, trace, "[%08x] connection opened %s", connection->getID(), socket->getIP().c_str()); L.log(net, trace, "[%05d] connection opened %s", connection->getID(), socket->getIP().c_str());
} }
} }