Optional monitors suggestion

Dmitry Olshansky via Digitalmars-d digitalmars-d at puremagic.com
Tue May 13 13:06:12 PDT 2014


13-May-2014 19:46, Yuriy пишет:
> 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.

Sounds cool, as I always was in favor of pay as you go principle.
Especially with thread-local as default, allocating monitor slot is dubious.


-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list