Is it possible to forbid synchronization on an object ?

chmike via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat May 28 09:24:21 PDT 2016


In my long quest to implement a flyweight pattern with objects 
instantiated at compile time, I was indirectly notified of the 
possible problem of synchronization.

In a flyweight pattern the user has the impression there are 
distinct instances where in fact objects with the same state 
(member variable value) are the same instance.

Since with play a trick with the users assumption, there is a 
high risk that user produces logically invalid code when using 
synchronization with such a flyweight object.

In order to avoid this problem I would need a solution to make 
synchronization impossible on an object ? It is preferable if 
this could be enforced at compile time. Is this possible with D ? 


More information about the Digitalmars-d-learn mailing list