Hidden members of Class objects

kinke noone at nowhere.com
Thu Mar 7 00:37:42 UTC 2024


On Thursday, 7 March 2024 at 00:28:17 UTC, Carl Sturtivant wrote:
> On Wednesday, 6 March 2024 at 23:45:00 UTC, H. S. Teoh wrote:
>> In D, there's a pointer to the vtable and another pointer to a 
>> Monitor object (used for synchronized methods).  There was 
>> talk about getting rid of the Monitor field years ago, but 
>> nothing has happened yet.
>
> Very interesting: is the monitor field ever touched by compiled 
> D code at any point nowadays? Or is it just vestigial?

It's (lazily initialized and) used by the 
`synchronized(<expression>)` statement (§3 of 
https://dlang.org/spec/statement.html#synchronized-statement) and 
the mentioned `synchronized` class methods 
(https://dlang.org/spec/class.html#synchronized-methods).


More information about the Digitalmars-d-learn mailing list