linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #05594
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2916: DebugFrame rewrite to using only the GUI thread, be cautioned it's very slow for now.
------------------------------------------------------------
revno: 2916
committer: iceman50 <bdcdevel@xxxxxxxxx>
branch nick: dcplusplus
timestamp: Thu 2012-05-10 14:05:05 -0500
message:
DebugFrame rewrite to using only the GUI thread, be cautioned it's very slow for now.
modified:
win32/DebugFrame.cpp
win32/DebugFrame.h
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'win32/DebugFrame.cpp'
--- win32/DebugFrame.cpp 2012-05-10 08:01:35 +0000
+++ win32/DebugFrame.cpp 2012-05-10 19:05:05 +0000
@@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-
+
#include "stdafx.h"
#include "DebugFrame.h"
@@ -123,8 +123,7 @@
}
updateStatus();
-
- start();
+
DebugManager::getInstance()->addListener(this);
}
@@ -171,12 +170,23 @@
setDirty(SettingsManager::BOLD_SYSTEM_LOG);
}
+void DebugFrame::addDbgLine(const string& cmd) {
+ callAsync([=] { cmdList.push_back(cmd); });
+
+ auto x = Util::emptyString;
+ {
+ if(cmdList.empty())
+ return;
+
+ x = cmdList.front();
+ cmdList.pop_front();
+ }
+ callAsync([=] { addLine(Text::toT(x)); });
+}
+
bool DebugFrame::preClosing() {
ClientManager::getInstance()->removeListener(this);
DebugManager::getInstance()->removeListener(this);
-
- stop = true;
- s.signal();
return true;
}
@@ -229,6 +239,37 @@
hubs->erase(idx);
}
-void DebugFrame::on(DebugCommand, const string& message) noexcept {
- callAsync([=] { addLine(Text::toT(message)); });
+void DebugFrame::on(DebugCommand, const string& aLine, int cmdType, const string& ip) noexcept {
+ auto url = hubs->getText();
+ switch(cmdType) {
+ case DebugManager::HUB_IN:
+ if(!showHubMsg)
+ return;
+ if(!filterByHub || Text::toT(ip) == url) {
+ callAsync([=] { addDbgLine("From Hub:\t\t<" + ip + ">\t \t" + aLine); });
+ }
+ break;
+ case DebugManager::HUB_OUT:
+ if(!showHubMsg)
+ return;
+ if(!filterByHub || Text::toT(ip) == url) {
+ callAsync([=] { addDbgLine("To Hub:\t\t<" + ip + ">\t \t" + aLine); });
+ }
+ break;
+ case DebugManager::CLIENT_IN:
+ if(!showClientMsg)
+ return;
+ if(!filterByHub || Text::toT(ip) == url) {
+ callAsync([=] { addDbgLine("From Client:\t\t<" + ip + ">\t \t" + aLine); });
+ }
+ break;
+ case DebugManager::CLIENT_OUT:
+ if(!showClientMsg)
+ return;
+ if(!filterByHub || Text::toT(ip) == url) {
+ callAsync([=] { addDbgLine("To Client:\t\t<" + ip + ">\t \t" + aLine); });
+ }
+ break;
+ default: dcassert(0);
+ }
}
=== modified file 'win32/DebugFrame.h'
--- win32/DebugFrame.h 2012-05-10 08:01:35 +0000
+++ win32/DebugFrame.h 2012-05-10 19:05:05 +0000
@@ -22,7 +22,6 @@
#include <dcpp/Client.h>
#include <dcpp/ClientManagerListener.h>
#include <dcpp/DebugManager.h>
-#include <dcpp/Semaphore.h>
#include <deque>
@@ -30,7 +29,7 @@
using std::deque;
-class DebugFrame : public StaticFrame<DebugFrame>, public Thread,
+class DebugFrame : public StaticFrame<DebugFrame>,
private DebugManagerListener,
private ClientManagerListener
{
@@ -47,46 +46,9 @@
static const string id;
const string& getId() const;
- void addLine(const tstring& msg);
-
private:
- bool stop;
- CriticalSection cs;
- Semaphore s;
deque<string> cmdList;
- int run() {
- setThreadPriority(Thread::LOW);
- string x = Util::emptyString;
- stop = false;
-
- while(true) {
- s.wait();
- if(stop)
- break;
-
- {
- Lock l(cs);
- if(cmdList.empty()) continue;
-
- x = cmdList.front();
- cmdList.pop_front();
- }
- addLine(Text::toT(x));
- }
-
- stop = false;
- return 0;
- }
-
- void addDbgLine(const string& cmd) {
- {
- Lock l(cs);
- cmdList.push_back(cmd);
- }
- s.signal();
- }
-
struct HubInfo : public FastAlloc<HubInfo> {
HubInfo(const tstring& aIp) : ip(aIp) { }
HubInfo(Client* client) : ip(Text::toT(client->getIpPort())) { }
@@ -111,6 +73,10 @@
void layout();
void updateStatus();
+
+ void addLine(const tstring& msg);
+ void addDbgLine(const string& cmd);
+
bool preClosing();
void clearMessages();
@@ -120,41 +86,6 @@
bool handleKeyDown(int c);
- void on(DebugManagerListener::DebugCommand, const string& aLine, int cmdType, const string& ip) throw() {
- auto url = hubs->getText();
- switch(cmdType) {
- case DebugManager::HUB_IN:
- if(!showHubMsg)
- return;
- if(!filterByHub || Text::toT(ip) == url) {
- addDbgLine("From Hub:\t\t<" + ip + ">\t \t" + aLine);
- }
- break;
- case DebugManager::HUB_OUT:
- if(!showHubMsg)
- return;
- if(!filterByHub || Text::toT(ip) == url) {
- addDbgLine("To Hub:\t\t<" + ip + ">\t \t" + aLine);
- }
- break;
- case DebugManager::CLIENT_IN:
- if(!showClientMsg)
- return;
- if(!filterByHub || Text::toT(ip) == url) {
- addDbgLine("From Client:\t\t<" + ip + ">\t \t" + aLine);
- }
- break;
- case DebugManager::CLIENT_OUT:
- if(!showClientMsg)
- return;
- if(!filterByHub || Text::toT(ip) == url) {
- addDbgLine("To Client:\t\t<" + ip + ">\t \t" + aLine);
- }
- break;
- default: dcassert(0);
- }
- }
-
// ClientManagerListener
virtual void on(ClientConnected, Client* c) noexcept;
virtual void on(ClientDisconnected, Client* c) noexcept;
@@ -163,7 +94,7 @@
void onHubRemoved(HubInfo* info);
// DebugManagerListener
- virtual void on(DebugCommand, const string& message) noexcept;
+ virtual void on(DebugManagerListener::DebugCommand, const string& aLine, int cmdType, const string& ip) noexcept;
};