Steven Schveighoffer wrote:
What I'd propose is either:
1) Create your own lock-free associative array (yup, reinvent the
wheel to introduce AA to the world of 'shared')
2) In this small case it may seem best (though mind that often such
cases do grow up to the point when you still need to rethink design):
Make your associative array __gshared and perform synchronization by
hand, i.e. create a static Mutex (from core.sync.mutex) variable and
initialize it in your CRegistry's static ctor, and then enclose all
access to associative array in synchronized(mutex) {} blocks.
Maybe concurrent-programming-in-D guru may propose simpler solution,
but I don't see another.
FWIW, the classinfo of a class is an object, and as such can be used as
sort of a global lock without having to use a static constructor:
synchronized(this.classinfo)
{
....
}
-Steve
Thanks. To my shame, I repeatedly keep forgetting about this.