|
Threads-Devel : |
From: Roland Schwarz (roland.schwarz_at_[hidden])
Date: 2006-03-06 12:37:47
David Abrahams wrote:
> [...] Mutex
> objects at global scope generally protect data at global scope.
> Unless that data has a trivial ctor, its initialization needs to be
> protected by a once routine anyway.
Most likely I am missing something here, but why would I need a once in
a global object
in the general case? Isn't this just for singletons or create on first use?
As I see it, guarding creation of a mutex at global scope is pointless
as long as I do not
guard the ctor of the global object it is refering to at the same time.
This is also one of the points I tried to express in one of my previous
posts already.
The protected data and its mutex should be tightly (explicitely)
coupled. Of course
a once like mechanism will be used under the hood to prevent the race
condition
during creation, but this need not be exposed to the user.
Roland