By ref and by pointer kills performance.

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Fri Feb 16 09:56:50 UTC 2024


On 16/02/2024 10:34 PM, Kagamin wrote:
> On Tuesday, 13 February 2024 at 13:30:11 UTC, Johan wrote:
> 
>     I hope someone can find the link to some DConf talk (me or Andrei)
>     or forum post where I talk about why LDC assumes that
>     |immutable(uint*)| points to /mutable/ (nota bene) data. The reason
>     is the mutable thread synchronization field in immutable class
>     variable storage (|__monitor|), combined with casting an immutable
>     class to an array of immutable bytes.
> 
>     Side-effects in-between immutable(uint*) lookup could run into a
>     synchronization event on the immutable data (i.e. mutating it).
> 
> Shouldn't it be okay for immutable(uint*) to not access |__monitor|? I 
> think, |__monitor| should work outside of type safety, like reference 
> counting, then immutability won't matter.

That covers immutable, but not immutable that has become const.

The only way I can see it working reliably is to simply turn off the 
mutex when it is immutable.


More information about the Digitalmars-d mailing list