- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi All , I am trying to use concurrent_bounded_queue for a producer/cosumer problem.
I want to have a background thread to collect the garbage. But my code is not working because the blocking "pop()"
never returns even if another thread adds an item to the Queue.
Most probably this could be something to do with my code and understanding . I expect the "push()"to notify the waiting "pop()" thread. Is it so ?
I am posting my basic idea here. Please help.
Thank you.
Zooli
I want to have a background thread to collect the garbage. But my code is not working because the blocking "pop()"
never returns even if another thread adds an item to the Queue.
Most probably this could be something to do with my code and understanding . I expect the "push()"to notify the waiting "pop()" thread. Is it so ?
I am posting my basic idea here. Please help.
Thank you.
Zooli
[bash]class GC { private : tbb::concurrent_bounded_queue nodequeue; public : GC() { } void operator()() { while(true) { Item* pItem = 0; nodequeue.pop(pItem); delete pItem; } } void finalize(Item* pItem) { nodequeue.push(pItem); } }; void main() { GC gc; thread thread1(gc); ...... /*Some other threads create and delete "Item" as main thread does below */ ...... Item* pItem = create(); /* Main thread also create one item*/ gc.finalize(pItem); /* Main thread adds "Item" for garbage collecton*/ thread1.join(); }; [/bash]
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi All,
Anybody?.
Thank you
Zooli
Anybody?.
Thank you
Zooli
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Zooli
There is a TBB forum which will be more appropriate for your query.
Jim
There is a TBB forum which will be more appropriate for your query.
Jim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Jim, I am posting it to TBB forum.

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