Quantcast
Channel: QtWebEngine
Viewing all articles
Browse latest Browse all 13965

Qt event with blocking queue implemented with boost

$
0
0
I have to use a blocking queue implemented with boost and emit a SIGNAL when the runner thread wakes up. What is the simplest way doing this? I’m interested in both fixes of my solution or different working solutions too. My solution is not working: shows the legendary “undefined reference to vtable” error. mediator.cpp: Mediator::Mediator(QObject *parent) : QObject(parent) {          ...   boost::thread myThread (callbackThread, this, &blocking_queue); }   static void callbackThread(Mediator* mediator, multi_consumer_mutexed_struct<item>* blocking_queue){     item it;;     for(;;){         try{             blocking_queue->wait_and_read(&it);             cout << "Item arrived" <<endl;             mediator->imageRefreshed();         } catch(const boost::thread_interrupted&){             break;         }     } }   void Mediator::imageRefreshed(){     emit imageRefreshedSignal(); } mediator.h: class Mediator : public QObject {     Q_OBJECT   public:     Mediator(QObject *parent);     ~Mediator();       void imageRefreshed();   signals:    void imageRefreshedSignal();   };   static void callbackThread(Mediator* mediator, multi_consumer_mutexed_struct<item>* blocking_queue); Without extending QObject and puts into callbackThread then everything is fine: the thread awakes when a new item arrived to the queue and read it out. But if I want to emit a signal I need to use the Q_OBJECT macro and extend QObject, and then the issues starts. Don’t ask about the multi_consumer_mutexed_struct itself: it works as a blocking queue and I just need to use that but it is not my product :-)

Viewing all articles
Browse latest Browse all 13965

Trending Articles