- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a case where I use a map as a cache which are stored in the thread local storage using enumerable_thread_specifc. There's a method if called, has to flush out all the caches. Meaning a method call from one thread has to somehow modify all other threads' (of the application) thread local storages to flush everything out. Is this possible at all? At first glance it doesn't seem like it, but just wanted to make sure.
Thank you very much.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You would have to drop out of the parallel phase first, because the threads should be able to assume that they have sole access to the data and that they don't need to release it when adding it to TLS (in the sense of release/acquire memory semantics).
Alternatives that come to mind are a shared concurrent_unordered_map, or pushing a copy of local-map changes to a concurrent_queue.
Alternatives that come to mind are a shared concurrent_unordered_map, or pushing a copy of local-map changes to a concurrent_queue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Whatnon-owner threadcould do is set a "flush" flag inside the thread local storage of the owner(s) desired to be flushed (or all threads). Any fill or empty (by owner of queue)subsequent to setting of flag results in flush first.
Doing it this way means you do not have to add a critical section, nor exit the thread pool.
The overhead to test this flag is negligable.
Jim Dempsey
Doing it this way means you do not have to add a critical section, nor exit the thread pool.
The overhead to test this flag is negligable.
Jim Dempsey

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