Add an erase() method to llvm::ThreadLocal.
authorOwen Anderson <resistor@mac.com>
Wed, 28 Jul 2010 22:49:43 +0000 (22:49 +0000)
committerOwen Anderson <resistor@mac.com>
Wed, 28 Jul 2010 22:49:43 +0000 (22:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109686 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/System/ThreadLocal.h
lib/System/ThreadLocal.cpp
lib/System/Unix/ThreadLocal.inc
lib/System/Win32/ThreadLocal.inc

index 3d44f62e959323051a94fa418ded88ae2362ce91..e6edd79d6ff1ae998614b3255fa027841467464b 100644 (file)
@@ -28,6 +28,7 @@ namespace llvm {
       virtual ~ThreadLocalImpl();
       void setInstance(const void* d);
       const void* getInstance();
+      void removeInstance();
     };
     
     /// ThreadLocal - A class used to abstract thread-local storage.  It holds,
@@ -43,6 +44,9 @@ namespace llvm {
       
       // set - Associates a pointer to an object with the current thread.
       void set(T* d) { setInstance(d); }
+      
+      // erase - Removes the pointer associated with the current thread.
+      void erase() { removeInstance(); }
     };
   }
 }
index e7054b528147189d2f02fde53de63aa793e48fd2..b84a8e7fd6f0c35698d07b423bf1450f72655e95 100644 (file)
@@ -67,6 +67,10 @@ const void* ThreadLocalImpl::getInstance() {
   return pthread_getspecific(*key);
 }
 
+void ThreadLocalImpl::removeInstance() {
+  setInstance(0);
+}
+
 }
 
 #elif defined(LLVM_ON_UNIX)
index 83d554d3077c7eaa765a5f7ac6283e53f4ac97e6..6769520a6fb66761bd095304eb69fcce0253048c 100644 (file)
@@ -22,4 +22,5 @@ ThreadLocalImpl::ThreadLocalImpl() { }
 ThreadLocalImpl::~ThreadLocalImpl() { }
 void ThreadLocalImpl::setInstance(const void* d) { data = const_cast<void*>(d);}
 const void* ThreadLocalImpl::getInstance() { return data; }
+void ThreadLocalImpl::removeInstance() { setInstance(0); }
 }
index c8f7840b00387f894e93d772fd5463d244fafafe..b8b933c4d29d9f8ae87bc436bb877dee4ac02a8d 100644 (file)
@@ -46,4 +46,8 @@ void ThreadLocalImpl::setInstance(const void* d){
   assert(errorcode != 0);
 }
 
+void ThreadLocalImpl::removeInstance() {
+  setInstance(0);
+}
+
 }