Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6830843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:39:58+00:00 2026-05-26T22:39:58+00:00

I use a Concurrency::concurrent_unordered_map successfully in my program (this is an implementation made by

  • 0

I use a Concurrency::concurrent_unordered_map successfully in my program (this is an implementation made by Microsoft). This is needed because multiple inserts/updates for elements and quite rare deletes are performed in a concurrent manner.

I know that this container (like all other concurrent containers) provides an unsafe erase() method – for erasing a node.

What would you think would be the best approach to make the erase process also thread safe ? This happens rarely as I’ve said (only because user intervention) and I would not like so much to have a critical section that has to be entered every time I perform a search on the container (or for that matter any other operations like iterator traversal and node updates). What do you think? I was also thinking on an event based mechanism but I don’t see how this is applicable here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:39:59+00:00Added an answer on May 26, 2026 at 10:39 pm

    Actually the involvement of a critical section to make the erase process concurrent safe defeats the purpose of using a concurrent container at all in my case. If one would use such an approach every operation that relates to the concurrent container would have to be guarded by the same lock (i.e. operations that until now wouldn’t have had to step on each others toe now have to wait on the same critical section). So this is by far the worst idea that renders your concurrent container useless in every situation that you might use it.

    An idea that addresses the mentioned inconveniences would be to use a Reader Writer lock. This allows shared reads but exclusive writes. One should protect the deletes with a writer lock and every other operation on the map with a reader lock like this:

        InsertOperation(key) -- this inserts the key in case is not present (and constructs a default constructed value)
        {
           reader_writer_lock::scoped_lock_read guard(reader_writer_lock);
           ...
        }
    
        value Find(key)
        {
            reader_writer_lock::scoped_lock_read guard(reader_writer_lock);
            ...
         }
    
         void EraseElement(key)
         {
            reader_writer_lock::**scoped_lock** guard(reader_writer_lock);
            ...
         }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

use this website a lot but first time posting. My program creates a number
When designing a database to use MVCC (Multi-Version Concurrency Control), you create tables with
This is a use case in member enrollment via web application/web service. We have
What are good ways to handle user input concurrency? As the answers to this
Today we use the concurrent mark sweep specifying it like this: -XX:+UseConcMarkSweepGC I seen
Can we use TBB concurrent_vector with openmp? Will concurrent updates be allowed?
We have several jobs that run concurrently that have to use the same config
'''use Jython''' import shutil print dir(shutil) There is no, shutil.move, how does one move
Use case: A does something on his box and gots stuck. He asks B
Use case: 3rd party application wants to programatically monitor a text file being generated

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.