summaryrefslogtreecommitdiff
path: root/zen/globals.h
diff options
context:
space:
mode:
authorDaniel Wilhelm <shieldwed@outlook.com>2018-05-09 00:11:35 +0200
committerDaniel Wilhelm <shieldwed@outlook.com>2018-05-09 00:11:35 +0200
commit015bb675d6eb177900c8ac94a6d35edc5ad90576 (patch)
treeedde4153ce9b2ba6bdaf9d3c0af0966ed6dfd717 /zen/globals.h
parent9.8 (diff)
downloadFreeFileSync-015bb675d6eb177900c8ac94a6d35edc5ad90576.tar.gz
FreeFileSync-015bb675d6eb177900c8ac94a6d35edc5ad90576.tar.bz2
FreeFileSync-015bb675d6eb177900c8ac94a6d35edc5ad90576.zip
9.9
Diffstat (limited to 'zen/globals.h')
-rwxr-xr-xzen/globals.h18
1 files changed, 9 insertions, 9 deletions
diff --git a/zen/globals.h b/zen/globals.h
index c57d97ff..2066c380 100755
--- a/zen/globals.h
+++ b/zen/globals.h
@@ -22,17 +22,17 @@ public:
Global()
{
static_assert(std::is_trivially_destructible<Pod>::value, "this memory needs to live forever");
- assert(!pod.inst && !pod.spinLock); //we depend on static zero-initialization!
+ assert(!pod_.inst && !pod_.spinLock); //we depend on static zero-initialization!
}
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)) ;
- ZEN_ON_SCOPE_EXIT(pod.spinLock = false);
- if (pod.inst)
- return *pod.inst;
+ while (pod_.spinLock.exchange(true)) ;
+ ZEN_ON_SCOPE_EXIT(pod_.spinLock = false);
+ if (pod_.inst)
+ return *pod_.inst;
return nullptr;
}
@@ -42,9 +42,9 @@ public:
if (newInst)
tmpInst = new std::shared_ptr<T>(std::move(newInst));
{
- while (pod.spinLock.exchange(true)) ;
- ZEN_ON_SCOPE_EXIT(pod.spinLock = false);
- std::swap(pod.inst, tmpInst);
+ while (pod_.spinLock.exchange(true)) ;
+ ZEN_ON_SCOPE_EXIT(pod_.spinLock = false);
+ std::swap(pod_.inst, tmpInst);
}
delete tmpInst;
}
@@ -58,7 +58,7 @@ private:
std::shared_ptr<T>* inst; // = nullptr;
std::atomic<bool> spinLock; // { false }; rely entirely on static zero-initialization! => avoid potential contention with worker thread during Global<> construction!
//serialize access; can't use std::mutex: has non-trival destructor
- } pod;
+ } pod_;
};
}
bgstack15