- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The use case is:
There are global shared buffer among different stages, and I employ flag array to control accesses to these buffers from different stages, which are usually the fi and fi+1 (producer and consumer)。
tbb::atomic<int> BufIsFull
tbb::atomic<unsinged int> WriteToBufNum, ReadToBufNum;
Now, because the filter(serial) can be executed by different threads on different items, so I have to make these flag array and index variable to these array are tbb::atomic(WriteToBufNum, ReadToBufNum).
I think, if I use thread_bound_filter, I don't need to declare WriteToBufNum as atomic type, which may reduce the overhead.
My questions are:
1) Can I have multi-thread_bound_filter in a pipeline?
2)in the example from manual, g is a thread_bound_filter
while (g.process_item()!=thread_bound_filter::end_of_stream)
continue;
t.join();
If have multi-filter, likeg, g1, g2, g3, do I have to do below? And Do I need to fork thread for each thread_bound_filter?
while (g.process_item()!=thread_bound_filter::end_of_stream && g1process_item()!=thread_bound_filter::end_of_stream && ......)
continue;
Thanks in advance!
Xingjing Lu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
1) Yes, you may have more than one thread-bound filter in a pipeline.
2) You may process each thread-bound filter in its own thread, or you may process all in the same thread. In the latter case, yes you will need to query every filter in the loop. But it should be
while (g1.process_item()!=end_of_stream || g2.process_item()!=end_of_stream /* || more the same way */ ) continue;
With &&, the loop would finish as soon as any single filter reached end_of_stream, possibly leaving unprocessed items in the pipeline.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
1) Yes, you may have more than one thread-bound filter in a pipeline.
2) You may process each thread-bound filter in its own thread, or you may process all in the same thread. In the latter case, yes you will need to query every filter in the loop. But it should be
while (g1.process_item()!=end_of_stream || g2.process_item()!=end_of_stream /* || more the same way */ ) continue;
With &&, the loop would finish as soon as any single filter reached end_of_stream, possibly leaving unprocessed items in the pipeline.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page