- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am writing a network service and considering using TBB instead of the traditional approach to handle threads myself (I'm a TBB newbie).
The service will essentially receive items that will need to be parsed, processed (with potential CPU-intensive calculation (secure hash) being performed on some of them) and then stored in a database.
I'm curious if somebody has suggestions as to which components of the TBB should be used to implement something like this efficiently.
My initial thought was to store the incoming items in a queue, and then pull the items off the queue in a fifo manner (though the ordering isn't important as long as there is no backlog) and process them in parallel.
Since the items will go through stages (parse, calculate, store), a pipeline seems suitable for that. I have been experimenting with a pipeline already, I'm having difficulty understanding how to use it when the input is a stream of data vs. a fixed set of data. If the first filter returns NULL (as would be the case when there is no more data at the moment), the pipeline just ends?
I imagine that this must be common application of the TBB, and was curious if some examples, templates exist for this?
Thank you for any suggestions and help.
The service will essentially receive items that will need to be parsed, processed (with potential CPU-intensive calculation (secure hash) being performed on some of them) and then stored in a database.
I'm curious if somebody has suggestions as to which components of the TBB should be used to implement something like this efficiently.
My initial thought was to store the incoming items in a queue, and then pull the items off the queue in a fifo manner (though the ordering isn't important as long as there is no backlog) and process them in parallel.
Since the items will go through stages (parse, calculate, store), a pipeline seems suitable for that. I have been experimenting with a pipeline already, I'm having difficulty understanding how to use it when the input is a stream of data vs. a fixed set of data. If the first filter returns NULL (as would be the case when there is no more data at the moment), the pipeline just ends?
I imagine that this must be common application of the TBB, and was curious if some examples, templates exist for this?
Thank you for any suggestions and help.
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can't our Network Router emulator example help here?
http://software.intel.com/en-us/articles/network-router-emulator/
--Vladimir
http://software.intel.com/en-us/articles/network-router-emulator/
--Vladimir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Vladimir,
Yes, that should definitely help. I will study that later today to see if I can adapt to meet my needs. In the meantime, how would the example need to be adapted so that processing doesn't stop when the queue is empty? It should just wait and continue as soon as there are items in the queue ... ?
Thank you.
Yes, that should definitely help. I will study that later today to see if I can adapt to meet my needs. In the meantime, how would the example need to be adapted so that processing doesn't stop when the queue is empty? It should just wait and continue as soon as there are items in the queue ... ?
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To not stop the pipeline if more data are expected to arrive from an external source, the input filter needs to wait for that data. If you already use concurrent_queue as the input source, the easiest way is probably to switch to concurrent_bounded_queue which have a blocking pop() method.
Be aware however that when the pipeline is blocked in the input filter, one thread (the one that started the pipeline) can be busy-waiting. A new flow graph API does not have this issue, and it can be used to build a pipeline as well (though it will require more things to be coded explicitly, compared to pipeline).
Be aware however that when the pipeline is blocked in the input filter, one thread (the one that started the pipeline) can be busy-waiting. A new flow graph API does not have this issue, and it can be used to build a pipeline as well (though it will require more things to be coded explicitly, compared to pipeline).
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