Reverted commit D3755446
[folly.git] / folly / ThreadLocal.h
index 55b7a246e9e00d94dbb45d92f7165a9ad5e4c516..b47742072a65a9c837872edf602b8fe4989b9137 100644 (file)
 
 #pragma once
 
-#include <boost/iterator/iterator_facade.hpp>
 #include <folly/Likely.h>
 #include <folly/Portability.h>
 #include <folly/ScopeGuard.h>
-#include <folly/SharedMutex.h>
+#include <boost/iterator/iterator_facade.hpp>
 #include <type_traits>
 #include <utility>
 
@@ -250,7 +249,6 @@ class ThreadLocalPtr {
     friend class ThreadLocalPtr<T,Tag>;
 
     threadlocal_detail::StaticMetaBase& meta_;
-    SharedMutex* accessAllThreadsLock_;
     std::mutex* lock_;
     uint32_t id_;
 
@@ -323,12 +321,10 @@ class ThreadLocalPtr {
     Accessor& operator=(const Accessor&) = delete;
 
     Accessor(Accessor&& other) noexcept
-        : meta_(other.meta_),
-          accessAllThreadsLock_(other.accessAllThreadsLock_),
-          lock_(other.lock_),
-          id_(other.id_) {
+      : meta_(other.meta_),
+        lock_(other.lock_),
+        id_(other.id_) {
       other.id_ = 0;
-      other.accessAllThreadsLock_ = nullptr;
       other.lock_ = nullptr;
     }
 
@@ -342,23 +338,20 @@ class ThreadLocalPtr {
       assert(&meta_ == &other.meta_);
       assert(lock_ == nullptr);
       using std::swap;
-      swap(accessAllThreadsLock_, other.accessAllThreadsLock_);
       swap(lock_, other.lock_);
       swap(id_, other.id_);
     }
 
     Accessor()
-        : meta_(threadlocal_detail::StaticMeta<Tag>::instance()),
-          accessAllThreadsLock_(nullptr),
-          lock_(nullptr),
-          id_(0) {}
+      : meta_(threadlocal_detail::StaticMeta<Tag>::instance()),
+        lock_(nullptr),
+        id_(0) {
+    }
 
    private:
     explicit Accessor(uint32_t id)
-        : meta_(threadlocal_detail::StaticMeta<Tag>::instance()),
-          accessAllThreadsLock_(&meta_.accessAllThreadsLock_),
-          lock_(&meta_.lock_) {
-      accessAllThreadsLock_->lock();
+      : meta_(threadlocal_detail::StaticMeta<Tag>::instance()),
+        lock_(&meta_.lock_) {
       lock_->lock();
       id_ = id;
     }
@@ -366,11 +359,8 @@ class ThreadLocalPtr {
     void release() {
       if (lock_) {
         lock_->unlock();
-        DCHECK(accessAllThreadsLock_ != nullptr);
-        accessAllThreadsLock_->unlock();
         id_ = 0;
         lock_ = nullptr;
-        accessAllThreadsLock_ = nullptr;
       }
     }
   };