Thread-safe singleton
-
wrote on 18 Aug 2010, 10:25 last edited by
I would like to hear your criticism about "this":http://developer.qt.nokia.com/wiki/Qt_thread-safe_singleton article.
-
wrote on 18 Aug 2010, 14:53 last edited by
I think that
@static T& instance()@should become
@static const T& instance()@UPD: And i think that you need to explain in that article what do you need call_once for, since this is a wiki page.
-
wrote on 18 Aug 2010, 15:44 last edited by
Why reference to T must be const, what if user want change internal state of class?
call_once it's thread-safe alternative for Double-Checked Locking pattern.
-
wrote on 19 Aug 2010, 05:48 last edited by
[quote author="SABROG" date="1282146241"]Why reference to T must be const, what if user want change internal state of class?[/quote]
Yep, you are right. My fault.
[quote author="SABROG" date="1282146241"]call_once it's thread-safe alternative for Double-Checked Locking pattern.[/quote]
I read about it :). What I meant is towrite just a few words of description on that page, so there is not just naked code.
4/4