object sync monitor ref

Pavel phondogo at gmail.com
Thu Nov 7 03:12:07 PST 2013


On Thursday, 7 November 2013 at 11:04:05 UTC, bearophile wrote:
> Pavel:
>
>> Why don't to introduce some annotation (property) for class 
>> needed to be synchronized or it descendants, according to it 
>> compiler will extend the size of class by the size of monitor 
>> structure (+1 allocation less).
>> Synchronization will be allowed when class or supers is 
>> annotated with this property (it can be checked by compiler).
>
> Out there there is surely some D code that lacks your 
> annotations and relies on the presence of the monitor pointer 
> in some class instances. I think your change is going to break 
> that code. So what deprecation/update path do you suggest to 
> use?
>
> Bye,
> bearophile

For example, new annotation can be introduced in next version of 
compiler, but the functionality will stay the same. So in case of 
compiler meet synchronized section on object of class not 
annotated with it then deprecation warning with message "class 
<some class> should be annotated with <annotation> to be used in 
synchronized expression".
After that (several next versions) make it error.


More information about the Digitalmars-d mailing list