- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am using TBB concurrent_queue class. It meets my needs except that I need to access the first element before popping it out of the queue (or put it back at front). As I understand from the document, one can't access first element or can't insert at the front like std:deque.
Any help on how to achieve this while maintaining concurrency as far as possible. I only need to access the front element and need to pop it out only if it meets some requirements - for example, to be consumed only after a particular time etc.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Accessing elements in the queue without popping is potentially unsafe (because the element can be accessed while another thread pops/removes it). The ability pushing elements to the front will make the implementation inefficient. You may want to consider concurrent_hash_map that allows accessing elements without extraction. Or consider concurrent_ordered_map that allows concurrent traversal and preserve ordering by key (similar to the queue).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Alex,
You may want to consider concurrent_hash_map that allows accessing elements without extraction.
I am not sure how concurrent_hash_map will help. I need the queue behaviour (FIFO).
Or consider concurrent_ordered_map that allows concurrent traversal and preserve ordering by key (similar to the queue).
Is there anything like concurrent_ordered_map? I can't find it in the documentation.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page