On Nov 15, 2012, at 3:16 AM, Regan Heath <re...@netmail.co.nz> wrote:
> 
> I suggested something similar as did Sönke:
> http://forum.dlang.org/thread/k7orpj$1tt5$1...@digitalmars.com?page=2#post-op.wnnuiio554xghj:40puck.auriga.bhead.co.uk
> 
> According to deadalnix the compiler magic I suggested to add the mutex isn't 
> possible:
> http://forum.dlang.org/thread/k7orpj$1tt5$1...@digitalmars.com?page=3#post-k7qsb5:242gqk:241:40digitalmars.com
> 
> Most of our ideas can be implemented with a wrapper template containing the 
> sync object (mutex, etc).

If I understand you correctly, you don't need anything that explicitly contains 
the sync object.  A global table of mutexes used according to the address of 
the value to be mutated should work.


> So... my feeling is that the best solution for "shared", ignoring the memory 
> barrier aspect which I would relegate to a different feature and solve a 
> different way, is..
> 
> 1. Remove the existing mutex from object.
> 2. Require that all objects passed to synchronized() {} statements implement 
> a synchable(*) interface
> 3. Design a Shared(*) wrapper template/struct that contains a mutex and 
> implements synchable(*)
> 4. Design a Shared(*) base class which contains a mutex and implements 
> synchable(*)

It would be nice to eliminate the mutex that's optionally built into classes 
now.  The possibility of having to allocate a new mutex on whatever random 
function call happens to be the first one with "synchronized" is kinda not 
great.

Reply via email to