A
ank
Hi,
I have some question about Singleton Pattern in C++.
I think I understand that static initialization order across
translation unit
is unspecified by the standard, but what can I do to ensure that some
kind of
static mutex is automatically initialized before the first use of it?
I cannot assume that this mutex is used only after executing main()
function because I need to use this mutex to lock singleton inside
initialization code and may apply double-check pattern.
Currently, I have very little experience with multithread programming.
I am not a native English speaker so my message may not be well
written.
Thanks in advance for any suggestions.
I have some question about Singleton Pattern in C++.
I think I understand that static initialization order across
translation unit
is unspecified by the standard, but what can I do to ensure that some
kind of
static mutex is automatically initialized before the first use of it?
I cannot assume that this mutex is used only after executing main()
function because I need to use this mutex to lock singleton inside
initialization code and may apply double-check pattern.
Currently, I have very little experience with multithread programming.
I am not a native English speaker so my message may not be well
written.
Thanks in advance for any suggestions.