www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - associative arrays

reply "deadalnix" <deadalnix gmail.com> writes:
Quick question, are they supposed to be stable ? Are they 
supposed to be thread safe when shared ?
Jun 02 2013
parent reply Walter Bright <newshound2 digitalmars.com> writes:
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.
Jun 02 2013
parent reply "deadalnix" <deadalnix gmail.com> writes:
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.
Jun 02 2013
parent Jonathan M Davis <jmdavisProg gmx.com> writes:
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
Jun 02 2013