Run the disassembler in it's own thread
authorChristoph Egger <christoph@christoph-egger.org>
Tue, 2 Jun 2015 21:16:06 +0000 (23:16 +0200)
committerChristoph Egger <christoph@christoph-egger.org>
Tue, 2 Jun 2015 21:16:25 +0000 (23:16 +0200)
Makes the gui responsive while the disassembler is working. Would also
allow for severall worker threads in the disassembler in the future --
and more cool stuff!

src/core/InformationManager.cxx
src/core/InformationManager.hxx
src/disassembler/Disassembler.hxx

index 500f79f1406f661c2a4ac53747fa053898ff0db6..7044381511b32ce270ad6fc32756bc6b2ce4b8bd 100644 (file)
@@ -28,6 +28,7 @@ InformationManager::InformationManager()
 }
 
 InformationManager::~InformationManager() {
+       disassemblerThread.quit();
        for (auto b : blocks)
                delete b.second;
 
@@ -36,14 +37,19 @@ InformationManager::~InformationManager() {
 
        for (auto i : plugins)
                delete i;
+       disassemblerThread.wait();
 }
 
 void InformationManager::reset(const std::string& filename) {
        this->filename = filename;
        disassembler.reset(createLLVMDisassembler(filename, this));
        emit resetEvent();
-       if (disassembler.get() != NULL)
-               disassembler.get()->start();
+       if (disassembler.get() != NULL) {
+               disassembler.get()->moveToThread(&disassemblerThread);
+               connect(&disassemblerThread, &QThread::started,
+                       disassembler.get(), &Disassembler::start);
+               disassemblerThread.start();
+       }
 }
 
 void InformationManager::load(const std::string& filename) {
index a866e0adf62c39791d8a8effe7453794f989cb60..f39f6e4335af3ef80c3cc5be58951293bc740e0b 100644 (file)
@@ -116,6 +116,7 @@ private:
        std::unique_ptr<QTemporaryFile> tmpfile;
        std::vector<QPluginLoader*> plugins;
 
+       QThread disassemblerThread;
        log4cxx::LoggerPtr logger;
 };
 
index ad35018e870bab74ae33da162d290be30e3a7832..6971177b63e27487029d643392d48b0f765be962 100644 (file)
@@ -20,13 +20,13 @@ public:
        Disassembler() {}
        virtual ~Disassembler() {}
 
-       virtual void start() = 0;
        virtual void getSymbols() = 0;
        virtual uint64_t entryAddress() = 0;
 
 #ifndef SWIG
 public slots:
 #endif
+       virtual void start() = 0;
        virtual Function * disassembleFunctionAt(uint64_t address) {
                return disassembleFunctionAt(address, "");
        }