D-Programming-Language/druntime — pull request #789 by yglukhov (2014-05-14 07:54:15+00:00)
Title: Optional monitors

This PR introduces optional monitors feature.
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.
Monitor finalization will only lookup for monitors, if a monitor was allocated at least once for the type of object being finalized.

If user wants to synchronize over some class, then he will probably want to add a __monitor field to it to gain performance bonus (no hash lookup will occur).