On Sun, 18 Dec 2011 11:55:10 -0000, Michel Fortin <[email protected]> wrote:

On 2011-12-18 04:35:08 +0000, Jonathan M Davis <[email protected]> said:

On Saturday, December 17, 2011 22:16:38 Michel Fortin wrote:
Shouldn't a properly implemented double-checked locking pattern be part
of the standard library? This way people will have a better chance of
not screwing up. I think the pattern is common enough to warrant it.
Well, from the sounds of it, the basic double-checked locking pattern would work just fine with a shared variable if shared were fully implemented, but since it's not, it doesn't work right now. So, I don't know that we need to do
anything other than finish implementing shared.

I meant something higher level so you don't even have to think about double-checked locking. Something like this:

        AssignOnce!(shared MyClass) c;
c = { new shared MyClass }; // the delegate literal is called only the first time
        c.blahblah(); // c is guarantied to be initialized at this point

...or something similar.

Something like..
http://linux.die.net/man/3/pthread_once

I wrote a windows version of that once (pun intended), and I *think* it works .. after reading Andrei's link I'm not so sure..

R

--
Using Opera's revolutionary email client: http://www.opera.com/mail/

Reply via email to