X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2FThreadCachedInt.h;h=3ed53b20bacf584e1951c70f8dd49a5f2fa893f2;hb=b95919855a9053e9d7f425ba6595d369f055fbb0;hp=10ccbbc5479b022da1e574ba0202893be625b22c;hpb=6039ee419aa6cf043e010297b29348267ab5be0d;p=folly.git diff --git a/folly/ThreadCachedInt.h b/folly/ThreadCachedInt.h index 10ccbbc5..3ed53b20 100644 --- a/folly/ThreadCachedInt.h +++ b/folly/ThreadCachedInt.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Facebook, Inc. + * Copyright 2017 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ class ThreadCachedInt : boost::noncopyable { void increment(IntT inc) { auto cache = cache_.get(); - if (UNLIKELY(cache == nullptr || cache->parent_ == nullptr)) { + if (UNLIKELY(cache == nullptr)) { cache = new IntCache(*this); cache_.reset(cache); } @@ -122,15 +122,6 @@ class ThreadCachedInt : boost::noncopyable { target_.store(newVal, std::memory_order_release); } - // This is a little tricky - it's possible that our IntCaches are still alive - // in another thread and will get destroyed after this destructor runs, so we - // need to make sure we signal that this parent is dead. - ~ThreadCachedInt() { - for (auto& cache : cache_.accessAllThreads()) { - cache.parent_ = nullptr; - } - } - private: std::atomic target_; std::atomic cacheSize_; @@ -173,9 +164,7 @@ class ThreadCachedInt : boost::noncopyable { } ~IntCache() { - if (parent_) { - flush(); - } + flush(); } }; };