|
Boost : |
Subject: Re: [boost] [thread] thread-safe static local
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2009-03-03 11:54:46
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Tuesday 03 March 2009, Oliver Kowalke wrote:
> Hi,
> I need a function 'get_default_X()' returning a reference to a singleton in
> a multithreaded env. I choosed Scott Meyers singleton pattern (static
> local) together with boost::call_once(). My this be a reasonable,
> threadsafe implementation?
I don't think so. Your once_flag is a local variable in Y's constructor, so I
don't see that the call_once accomplishes anything.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAkmtYNcACgkQ5vihyNWuA4UJyACfciR5l1vbwg7wMPUISDIQUhoN
AfYAoLbHeovjJsaKzRuY0lYSmF5l0E1F
=E/Pf
-----END PGP SIGNATURE-----
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk