Does D have equivalent of Java util.concurrent?

rikki cattermole rikki at cattermole.co.nz
Sun Apr 28 09:24:52 UTC 2019


On 28/04/2019 9:05 PM, Dibyendu Majumdar wrote:
> On Sunday, 28 April 2019 at 08:47:06 UTC, rikki cattermole wrote:
>> On 28/04/2019 8:34 PM, Dibyendu Majumdar wrote:
>>> I have to understand the model. Suppose some mutable data is passed 
>>> around between threads. I don't really know as I haven't read this in 
>>> detail - but my question is this: is there a cost to accessing data 
>>> across threads?
>>
>> Same cost compared to C.
> 
> Is there a document that describes the rules regarding concurrent memory 
> access, such as the Java Memory Model or C++ Memory Model 
> (https://en.cppreference.com/w/cpp/language/memory_model)?
> 
> Suppose some data needs to be shared between threads, and it is not 
> global data. Does it need to be marked 'shared'? Reading Andrei's doc I 
> got the impression that the 'shared' mark has a cost.
> 
> Thanks

shared does nothing.
There is strong desire to remove it, most people cast it away since its 
just a pain in the type system (ignoring its behavior of __gshared for 
globals).

I think you're over thinking it.

Yes you do need to use some form of memory synchronization strategy.
No, the language does not force it.
Yes the standard library does offer some solutions to this end.
No, the language is by default unsafe and you're free to do anything you 
want including BSOD your computer. This is what native languages offer you.


More information about the Digitalmars-d mailing list