Fix another race in Notification Queue
[folly.git] / folly / ThreadLocal.h
index 4ecc757ad440dc983c6842a010e905395d31bdcd..ad111168ee55df75ff8e19e30fafe7fd267467fd 100644 (file)
@@ -37,9 +37,9 @@
 #ifndef FOLLY_THREADLOCAL_H_
 #define FOLLY_THREADLOCAL_H_
 
-#include "folly/Portability.h"
+#include <folly/Portability.h>
 #include <boost/iterator/iterator_facade.hpp>
-#include "folly/Likely.h"
+#include <folly/Likely.h>
 #include <type_traits>
 
 
@@ -50,7 +50,7 @@ enum class TLPDestructionMode {
 };
 }  // namespace
 
-#include "folly/detail/ThreadLocalDetail.h"
+#include <folly/detail/ThreadLocalDetail.h>
 
 namespace folly {
 
@@ -128,7 +128,8 @@ class ThreadLocal {
  * NOTE: Apple platforms don't support the same semantics for __thread that
  *       Linux does (and it's only supported at all on i386). For these, use
  *       pthread_setspecific()/pthread_getspecific() for the per-thread
- *       storage.
+ *       storage.  Windows (MSVC and GCC) does support the same semantics
+ *       with __declspec(thread)
  */
 
 template<class T, class Tag=void>
@@ -164,6 +165,13 @@ class ThreadLocalPtr {
     return *get();
   }
 
+  T* release() {
+    threadlocal_detail::ElementWrapper& w =
+      threadlocal_detail::StaticMeta<Tag>::get(id_);
+
+    return static_cast<T*>(w.release());
+  }
+
   void reset(T* newPtr = nullptr) {
     threadlocal_detail::ElementWrapper& w =
       threadlocal_detail::StaticMeta<Tag>::get(id_);