On Friday, 7 February 2014 at 11:31:14 UTC, Stanislav Blinov
wrote:
On Friday, 7 February 2014 at 10:25:52 UTC, TC wrote:
Should't be the LockSingleton implemented like this instead?
class LockSingleton
{
static auto get()
{
if (_instance is null)
(_instance is null) will most likely not be an atomic
operation. References are two words. Imagine that one thread
writes half a reference inside synchronized {}, then goes to
sleep. What would the thread that gets to that 'if' return? I'd
say it'll return "ouch".
Scratch that.