Optional monitors suggestion

Yuriy via Digitalmars-d digitalmars-d at puremagic.com
Tue May 13 08:46:49 PDT 2014


Hello, I've played a bit with monitors, trying to make them 
optional, and here's what i've come up with:
https://github.com/yglukhov/dmd/tree/optional_monitor
https://github.com/yglukhov/druntime/tree/optional_monitors

The whole idea is that Object doesn't contain __monitor field 
anymore.
TypeInfo_Class will hold a monitor offset, if a class defines one 
(like void* __monitor), or -1.
Monitor lookup is done with a hash map, if monitorOffset is -1.
The hash map is protected by a primitive RW spin lock.
The only downside i see here is that finalization of every object 
will now lookup for a corresponding monitor, if it's class 
doesn't define embedded one.
Tested on Mac, but i think it should work anywhere.

Your feedback is very appreciated. Thanx.


More information about the Digitalmars-d mailing list