Remove dep on boost_thread
authorDave Watson <davejwatson@fb.com>
Fri, 14 Aug 2015 18:56:32 +0000 (11:56 -0700)
committerfacebook-github-bot-9 <folly-bot@fb.com>
Fri, 14 Aug 2015 19:20:35 +0000 (12:20 -0700)
Summary: Remove recently introduced dependency on boost_thread by breaking EventBaseLocal off to its own rule

Introduced in D2203063

Reviewed By: @​mzlee

Differential Revision: D2301943

folly/io/async/EventBase.cpp
folly/io/async/EventBase.h
folly/io/async/EventBaseLocal.cpp
folly/io/async/EventBaseLocal.h

index 1f23b2b60df72651048332b97dd58bb496bd73e2..0bf7951f40bb98442b38cb3bd65a26d0bed33a5d 100644 (file)
@@ -21,7 +21,6 @@
 #include <folly/io/async/EventBase.h>
 
 #include <folly/ThreadName.h>
-#include <folly/io/async/EventBaseLocal.h>
 #include <folly/io/async/NotificationQueue.h>
 
 #include <boost/static_assert.hpp>
@@ -239,14 +238,12 @@ EventBase::~EventBase() {
     event_base_free(evb_);
   }
 
-#if !defined(ANDROID) && !defined(__ANDROID__) && !defined(__APPLE__)
   {
     std::lock_guard<std::mutex> lock(localStorageMutex_);
     for (auto storage : localStorageToDtor_) {
       storage->onEventBaseDestruction(*this);
     }
   }
-#endif
   VLOG(5) << "EventBase(): Destroyed.";
 }
 
index e15465c9e12fb673f686d6d9a12976a401764f9b..908aa6af4ac0f2edce8d3d0765956b0b9948bf78 100644 (file)
@@ -47,13 +47,17 @@ typedef std::function<void()> Cob;
 template <typename MessageT>
 class NotificationQueue;
 
-#if !defined(ANDROID) && !defined(__ANDROID__) && !defined(__APPLE__)
 namespace detail {
 class EventBaseLocalBase;
+
+class EventBaseLocalBaseBase {
+ public:
+  virtual void onEventBaseDestruction(EventBase& evb) = 0;
+  virtual ~EventBaseLocalBaseBase() = default;
+};
 }
 template <typename T>
 class EventBaseLocal;
-#endif
 
 class EventBaseObserver {
  public:
@@ -740,14 +744,12 @@ class EventBase : private boost::noncopyable,
   // allow runOnDestruction() to be called from any threads
   std::mutex onDestructionCallbacksMutex_;
 
-#if !defined(ANDROID) && !defined(__ANDROID__) && !defined(__APPLE__)
   // see EventBaseLocal
   friend class detail::EventBaseLocalBase;
   template <typename T> friend class EventBaseLocal;
   std::mutex localStorageMutex_;
   std::unordered_map<uint64_t, std::shared_ptr<void>> localStorage_;
-  std::unordered_set<detail::EventBaseLocalBase*> localStorageToDtor_;
-#endif
+  std::unordered_set<detail::EventBaseLocalBaseBase*> localStorageToDtor_;
 };
 
 } // folly
index c8533e6d97a60495236a8a855a96ea986253c316..0f08b639e39f4a64d8c2d45acadce3d6923045a0 100644 (file)
@@ -14,8 +14,6 @@
  * limitations under the License.
  */
 
-#if !defined(ANDROID) && !defined(__ANDROID__) && !defined(__APPLE__)
-
 #include <folly/io/async/EventBaseLocal.h>
 #include <atomic>
 #include <thread>
@@ -98,5 +96,3 @@ void EventBaseLocalBase::setVoidUnlocked(
 
 std::atomic<uint64_t> EventBaseLocalBase::keyCounter_{0};
 }}
-
-#endif // !__ANDROID__ && !ANDROID && !__APPLE__
index 5681fac67f4aa56c32fb5df4d687408691698651..334cb601e40ba651da14404a0b11868da07a5d66 100644 (file)
@@ -16,8 +16,6 @@
 
 #pragma once
 
-#if !defined(ANDROID) && !defined(__ANDROID__) && !defined(__APPLE__)
-
 #include <boost/noncopyable.hpp>
 #include <folly/Synchronized.h>
 #include <folly/io/async/EventBase.h>
@@ -30,12 +28,12 @@ namespace folly {
 
 namespace detail {
 
-class EventBaseLocalBase : boost::noncopyable {
+class EventBaseLocalBase : public EventBaseLocalBaseBase, boost::noncopyable {
  public:
   EventBaseLocalBase() {}
   virtual ~EventBaseLocalBase();
   void erase(EventBase& evb);
-  void onEventBaseDestruction(EventBase& evb);
+  void onEventBaseDestruction(EventBase& evb) override;
 
  protected:
   void setVoid(EventBase& evb, std::shared_ptr<void>&& ptr);
@@ -128,5 +126,3 @@ class EventBaseLocal : public detail::EventBaseLocalBase {
 
 
 }
-
-#endif // !__ANDROID__ && !ANDROID && !__APPLE__