From 32d467b876d645fc3280818bfd15c912b91bc1fd Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Tue, 27 Jun 2017 05:16:10 +0300 Subject: std::call_once: ```c++ instead of simply ``` --- _posts/2015-07-03-std-call-once-bug.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to '_posts') diff --git a/_posts/2015-07-03-std-call-once-bug.md b/_posts/2015-07-03-std-call-once-bug.md index 313fc6a..5a263fc 100644 --- a/_posts/2015-07-03-std-call-once-bug.md +++ b/_posts/2015-07-03-std-call-once-bug.md @@ -30,7 +30,7 @@ C++11 and singletons Anyway, the story begins with me trying to implement the singleton pattern using C++11 facilities like this: -``` +```c++ #include template @@ -73,7 +73,7 @@ Neat, huh? Now other classes can inherit from `Singleton`, implementing the singleton pattern effortlessly: -``` +```c++ class Logger : public Singleton { private: @@ -90,7 +90,7 @@ If it was, I wouldn't, of course, need to employ this `std::call_once` trickery, and the implementation would be much simpler, i.e. something like this: -``` +```c++ class Logger { public: @@ -140,7 +140,7 @@ required some logging to be done. I thought that I could simply call `Logger::get_instance` inside `Duke`'s constructor, and everything looked fine at first glance. -``` +```c++ #include #include @@ -186,7 +186,7 @@ Now, what happens if I have two threads, one using the `Duke` instance, and the other logging something? Like in this example: -``` +```c++ #include namespace -- cgit v1.2.3