#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>
};
} // namespace
-#include "folly/detail/ThreadLocalDetail.h"
+#include <folly/detail/ThreadLocalDetail.h>
namespace folly {
* 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>
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_);