diff options
author | Owen Anderson <resistor@mac.com> | 2009-05-16 07:20:52 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-05-16 07:20:52 +0000 |
commit | 18ad4cb95dd4092eeb29d9c5233d18d9f918b040 (patch) | |
tree | 86743ede8457fe8787971b4414985e345e9a30a5 /include/llvm/Support/ManagedStatic.h | |
parent | 0394c4fb3d271b3a6736f167b812bbe445ddb5e9 (diff) | |
download | external_llvm-18ad4cb95dd4092eeb29d9c5233d18d9f918b040.tar.gz external_llvm-18ad4cb95dd4092eeb29d9c5233d18d9f918b040.tar.bz2 external_llvm-18ad4cb95dd4092eeb29d9c5233d18d9f918b040.zip |
Back out the thread-safe ManagedStatic for now. Too many people have too many problems with it for the moment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71931 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/ManagedStatic.h')
-rw-r--r-- | include/llvm/Support/ManagedStatic.h | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/include/llvm/Support/ManagedStatic.h b/include/llvm/Support/ManagedStatic.h index a504be31d8..d0298e495d 100644 --- a/include/llvm/Support/ManagedStatic.h +++ b/include/llvm/Support/ManagedStatic.h @@ -14,8 +14,6 @@ #ifndef LLVM_SUPPORT_MANAGED_STATIC_H #define LLVM_SUPPORT_MANAGED_STATIC_H -#include "llvm/System/Atomic.h" - namespace llvm { /// object_deleter - Helper method for ManagedStatic. @@ -28,8 +26,6 @@ void object_deleter(void *Ptr) { /// ManagedStaticBase - Common base class for ManagedStatic instances. class ManagedStaticBase { protected: - mutable sys::cas_flag InitFlag; - // This should only be used as a static variable, which guarantees that this // will be zero initialized. mutable void *Ptr; @@ -51,35 +47,23 @@ public: /// template<class C> class ManagedStatic : public ManagedStaticBase { -private: - void checkInit() { - sys::cas_flag OldFlag = sys::CompareAndSwap(&InitFlag, 1, 0); - if (OldFlag == 0) { - LazyInit(); - sys::MemoryFence(); - InitFlag = 2; - } else if (OldFlag == 1) { - while (InitFlag == 1) ; - sys::MemoryFence(); - } - } public: // Accessors. C &operator*() { - checkInit(); + if (!Ptr) LazyInit(); return *static_cast<C*>(Ptr); } C *operator->() { - checkInit(); + if (!Ptr) LazyInit(); return static_cast<C*>(Ptr); } const C &operator*() const { - checkInit(); + if (!Ptr) LazyInit(); return *static_cast<C*>(Ptr); } const C *operator->() const { - checkInit(); + if (!Ptr) LazyInit(); return static_cast<C*>(Ptr); } |