how to assign to shared obj.systime?

mw mingwu at gmail.com
Fri Jul 10 18:30:16 UTC 2020


On Friday, 10 July 2020 at 17:35:56 UTC, Steven Schveighoffer 
wrote:
> Mark your setTime as shared, then cast away shared (as you 
> don't need atomics once it's locked), and assign:
>
> synchronized setTime(ref SysTime t) shared {
>     (cast()this).time = t;
> }

I know I can make it work by casting, my question is:

we had a lock on the owning shared object already, WHY we still 
need the cast to make it compile.



More information about the Digitalmars-d-learn mailing list