associative arrays

Jonathan M Davis jmdavisProg at gmx.com
Sun Jun 2 19:20:05 PDT 2013


On Monday, June 03, 2013 04:13:21 deadalnix wrote:
> On Sunday, 2 June 2013 at 18:55:15 UTC, Walter Bright wrote:
> > On 6/2/2013 11:37 AM, deadalnix wrote:
> >> Quick question, are they supposed to be stable ? Are they
> >> supposed to be thread
> >> safe when shared ?
> > 
> > Declaring anything shared does not make it "thread safe". You
> > still have to synchronize, etc.
> 
> Sure, but what is the goal we want to reach. Thread safe hash
> table are know technology and can surely be implemented.

I would be very surprised to ever see the build-in AAs doing that. Not only 
are there all kinds of problems in their implementation, but making them 
synchronize would incur overhead which is unnecessary for most programs. If 
you want to use them in a shared context, then make them shared and protect 
them with mutex or synchronized blocks. That's the normal thing to do. And if 
you want one that does the synchronization automatically, then create a 
wrapper for the built-in AA which is synchronized. We may very well add that 
to std.container at some point, but the built-in AA implementation isn't going 
to function that way in and of itself.

- Jonathan M Davis


More information about the Digitalmars-d mailing list