- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am using qt for gui purpose and tbb for parallel processing.
but i couldnt use both at same time.
my task is play video (background subtraction - image processing) using tbb and qt.
so after press play button using qt gui, tbb wil get start its process. at that time i couldnt able to press any otehr buttons in my gui. it getsstruck. but after tbb loops finishes i can able to access the gui.
I am using tbb22 version.
Link Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I dont think its a problem of conflict between qt and tbb but just a bug in your code.
You would probably receive more help if you posted the relevant code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting nagy
I dont think its a problem of conflict between qt and tbb but just a bug in your code.
You would probably receive more help if you posted the relevant code.
Also, what version of Qt are you using?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
qt-win-opensource-4.6.2-vs2008
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'd rather call it design flaw than a conventional bug :). The loss of responsiveness is likely caused by invoking parallel algorithm directly from the GUI thread. Naturally this stalls GUI dispatch loop until the parallel computation is completed.
Instead of running TBB algorithm in the button event handler, use tbb::task::enqueue() method to schedule a task that will then run the parallel computation in its execute() method. When the parallel processing is finished, post a custom window message to the GUI thread to notify it that the calculation is done. In the handler of this message GUI will appropriately update its windows.
See the chapter 8 of the new TBB design patterns document for more detailed discussion of this and related scenarios.
Instead of running TBB algorithm in the button event handler, use tbb::task::enqueue() method to schedule a task that will then run the parallel computation in its execute() method. When the parallel processing is finished, post a custom window message to the GUI thread to notify it that the calculation is done. In the handler of this message GUI will appropriately update its windows.
See the chapter 8 of the new TBB design patterns document for more detailed discussion of this and related scenarios.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
sorry for late reply,
Andrey can you share any simple code to do that implementation usingtbb::task::enqueue()? i couldnt understand the in that pdf, so plz write small code for above implementation.
I am using tbb22 version, therefore it doesnt have enqueue method...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, I've never used QT in practice, so my illustration of asynchronous signal sending may be not quite correct (or there are simpler ways). If it does not work, please refer to QT forums, and don't for get to report back here :) .
Here the outline:
Here the outline:
[bash]class MyWidget : public QWidget { // ... public: void onOffloadedWorkCompletion() { /* update view */ } }; class OffloadingTask : public tbb::task { MyWidget* my_widget; public: tbb::task* execute () { // ... Do any preparative activities // Run parallel processing tbb::parallel_for( /*argument*/ ); // Send asynchronous signal to the GUI thread QMetaObject::invokeMethod( my_widget, "onOffloadedWorkCompletion", Qt::QueuedConnection); } OffloadingTask ( MyWidget* w ) : my_widget(w) {} }; void MyWidget::onPushButton() { tbb::task::enqueue( *new (tbb::task::allocate_root()) OffloadingTask(this) ); } [/bash]
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page