Question on shared memory concurrency

evilrat evilrat666 at gmail.com
Mon Mar 4 17:00:53 UTC 2024


On Monday, 4 March 2024 at 16:02:50 UTC, Andy Valencia wrote:
> On Monday, 4 March 2024 at 03:42:48 UTC, Richard (Rikki) Andrew 
> Cattermole wrote:
>> A way to do this without spawning threads manually:
>>...
>
> Thank you!  Of course, a thread dispatch per atomic increment 
> is going to be s.l.o.w., so not surprising you had to trim the 
> iterations.
>
> Bug I still hope to be able to share memory between spawned 
> threads, and if it isn't a shared ref of a shared variable, 
> then what would it be?  Do I have to use the memory allocator?

There is `__gshared` type qualifier, but unlike plain `shared` it 
is up to you to ensure valid concurrency access as stated in the 
docs.

https://dlang.org/spec/const3.html#shared_global


More information about the Digitalmars-d-learn mailing list