- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
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 kopiert
3 Antworten
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Hi All,
Anybody?.
Thank you
Zooli
Anybody?.
Thank you
Zooli
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
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
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Thank you Jim, I am posting it to TBB forum.
Antworten
Themen-Optionen
- RSS-Feed abonnieren
- Thema als neu kennzeichnen
- Thema als gelesen kennzeichnen
- Diesen Thema für aktuellen Benutzer floaten
- Lesezeichen
- Abonnieren
- Drucker-Anzeigeseite