- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi folks,
I'm currently migrating to TBB, anyway, I will have the same question... I've attached my sources to explain.
My consumer thread could be waiting on a queue.pop(), since it should be signaled on concurrent queue only... what's the better way to deal with this? I know that a queue will never have a terminate() method :P it's just a workaround for now.
Thanks in advance,
William
concurrent_queue-inl.h
test_consumer.h
I'm currently migrating to TBB, anyway, I will have the same question... I've attached my sources to explain.
My consumer thread could be waiting on a queue.pop(), since it should be signaled on concurrent queue only... what's the better way to deal with this? I know that a queue will never have a terminate() method :P it's just a workaround for now.
Thanks in advance,
William
concurrent_queue-inl.h
test_consumer.h
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Something like this maybe?
void terminate()
{
queue.push(nullptr);
}
void run()
{
History* hist = queue.pop();
bool terminated = hist == nullptr;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
pushing a NULL value works only on a blockingqueue, right?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I dont understand? pop() is blocking in all tbbs concurrent queues, try_pop is non-blocking. And why would it only work on a blockingqueue?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My mistake. Thanks a lot. It solved my problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting poetinha
My mistake. Thanks a lot. It solved my problem.
Be careful, some use patterns can corrupt memory/crash:
http://software.intel.com/en-us/forums/showthread.php?t=73928&o=d&s=lr

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