Proposal: ClassInfo hasFinalizer field

Robert Jacques sandford at jhu.edu
Sat Jun 4 22:22:30 PDT 2011


On Sun, 05 Jun 2011 00:28:58 -0400, dsimcha <dsimcha at yahoo.com> wrote:

> On 6/4/2011 11:45 PM, Walter Bright wrote:
>>
>> One issue is that if someone derives from a class and adds a finalizer.
>
> One issue I did forget, though, is that these "empty" finalizers do  
> deallocate the object's monitor.  (For those not familiar with these  
> details, D classes contain a hidden monitor field that is null  
> initially.  When you do synchronized(someClass), the monitor is lazily  
> initialized.)  I guess we could get around this by setting the finalize  
> bit in the monitor initialization code rather than upfront, for classes  
> that don't do any other finalization.  This would almost always be more  
> efficient than the status quo since very few classes use monitors.

They shouldn't. Monitors can be shared across objects.


More information about the Digitalmars-d mailing list