Optional monitors suggestion

Yuriy via Digitalmars-d digitalmars-d at puremagic.com
Tue May 13 23:41:10 PDT 2014


> 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.

Ok, i think i've found a simple yet effective solution.
Adding a flag to ClassFlags: hasAllocatedMonitors.
Mark m_flags with this flag in runtime, when monitor is allocated.
When finalizing, check this flag to know if we need to lookup the 
monitors.

This way the only types that suffer would be those who don't 
define embedded __monitor, but still use synchronized() over them.

Would that be an ultimate win-win solution?


More information about the Digitalmars-d mailing list