summaryrefslogtreecommitdiff
path: root/zen/globals.h
diff options
context:
space:
mode:
authorDaniel Wilhelm <shieldwed@outlook.com>2016-10-29 11:41:53 +0200
committerDaniel Wilhelm <shieldwed@outlook.com>2016-10-29 11:41:53 +0200
commit7302bb4484d517a72cdffbd13ec7a9f2324cde01 (patch)
tree17d2964c6768d49510206836a496fb1802a63e08 /zen/globals.h
parent8.5 (diff)
downloadFreeFileSync-7302bb4484d517a72cdffbd13ec7a9f2324cde01.tar.gz
FreeFileSync-7302bb4484d517a72cdffbd13ec7a9f2324cde01.tar.bz2
FreeFileSync-7302bb4484d517a72cdffbd13ec7a9f2324cde01.zip
8.6
Diffstat (limited to 'zen/globals.h')
-rw-r--r--zen/globals.h28
1 files changed, 14 insertions, 14 deletions
diff --git a/zen/globals.h b/zen/globals.h
index ff8c890d..123028c7 100644
--- a/zen/globals.h
+++ b/zen/globals.h
@@ -18,10 +18,10 @@ template <class T>
class Global
{
public:
- Global() { static_assert(std::is_trivially_destructible<Pod>::value, "this memory needs to live forever"); }
- explicit Global(std::unique_ptr<T>&& newInst) { set(std::move(newInst)); }
- ~Global() { set(nullptr); }
-
+ Global() { static_assert(std::is_trivially_destructible<Pod>::value, "this memory needs to live forever"); }
+ explicit Global(std::unique_ptr<T>&& newInst) { set(std::move(newInst)); }
+ ~Global() { set(nullptr); }
+
std::shared_ptr<T> get() //=> return std::shared_ptr to let instance life time be handled by caller (MT usage!)
{
while (pod.spinLock.exchange(true)) ;
@@ -45,19 +45,19 @@ public:
}
private:
- //avoid static destruction order fiasco: there may be accesses to "Global<T>::get()" during process shutdown
- //e.g. _("") used by message in debug_minidump.cpp or by some detached thread assembling an error message!
- //=> use trivially-destructible POD only!!!
- struct Pod
- {
- std::shared_ptr<T>* inst = nullptr;
- //serialize access; can't use std::mutex: has non-trival destructor
- std::atomic<bool> spinLock { false };
- } pod;
+ //avoid static destruction order fiasco: there may be accesses to "Global<T>::get()" during process shutdown
+ //e.g. _("") used by message in debug_minidump.cpp or by some detached thread assembling an error message!
+ //=> use trivially-destructible POD only!!!
+ struct Pod
+ {
+ std::shared_ptr<T>* inst = nullptr;
+ //serialize access; can't use std::mutex: has non-trival destructor
+ std::atomic<bool> spinLock { false };
+ } pod;
};
#if defined _MSC_VER && _MSC_VER < 1900
-#error function scope static initialization is not yet thread-safe!
+ #error function scope static initialization is not yet thread-safe!
#endif
}
bgstack15