Commit bb7d2e02 authored by Dave Watson's avatar Dave Watson Committed by facebook-github-bot-9

Remove dep on boost_thread

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
parent fb209751
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include <folly/io/async/EventBase.h> #include <folly/io/async/EventBase.h>
#include <folly/ThreadName.h> #include <folly/ThreadName.h>
#include <folly/io/async/EventBaseLocal.h>
#include <folly/io/async/NotificationQueue.h> #include <folly/io/async/NotificationQueue.h>
#include <boost/static_assert.hpp> #include <boost/static_assert.hpp>
...@@ -239,14 +238,12 @@ EventBase::~EventBase() { ...@@ -239,14 +238,12 @@ EventBase::~EventBase() {
event_base_free(evb_); event_base_free(evb_);
} }
#if !defined(ANDROID) && !defined(__ANDROID__) && !defined(__APPLE__)
{ {
std::lock_guard<std::mutex> lock(localStorageMutex_); std::lock_guard<std::mutex> lock(localStorageMutex_);
for (auto storage : localStorageToDtor_) { for (auto storage : localStorageToDtor_) {
storage->onEventBaseDestruction(*this); storage->onEventBaseDestruction(*this);
} }
} }
#endif
VLOG(5) << "EventBase(): Destroyed."; VLOG(5) << "EventBase(): Destroyed.";
} }
......
...@@ -47,13 +47,17 @@ typedef std::function<void()> Cob; ...@@ -47,13 +47,17 @@ typedef std::function<void()> Cob;
template <typename MessageT> template <typename MessageT>
class NotificationQueue; class NotificationQueue;
#if !defined(ANDROID) && !defined(__ANDROID__) && !defined(__APPLE__)
namespace detail { namespace detail {
class EventBaseLocalBase; class EventBaseLocalBase;
class EventBaseLocalBaseBase {
public:
virtual void onEventBaseDestruction(EventBase& evb) = 0;
virtual ~EventBaseLocalBaseBase() = default;
};
} }
template <typename T> template <typename T>
class EventBaseLocal; class EventBaseLocal;
#endif
class EventBaseObserver { class EventBaseObserver {
public: public:
...@@ -740,14 +744,12 @@ class EventBase : private boost::noncopyable, ...@@ -740,14 +744,12 @@ class EventBase : private boost::noncopyable,
// allow runOnDestruction() to be called from any threads // allow runOnDestruction() to be called from any threads
std::mutex onDestructionCallbacksMutex_; std::mutex onDestructionCallbacksMutex_;
#if !defined(ANDROID) && !defined(__ANDROID__) && !defined(__APPLE__)
// see EventBaseLocal // see EventBaseLocal
friend class detail::EventBaseLocalBase; friend class detail::EventBaseLocalBase;
template <typename T> friend class EventBaseLocal; template <typename T> friend class EventBaseLocal;
std::mutex localStorageMutex_; std::mutex localStorageMutex_;
std::unordered_map<uint64_t, std::shared_ptr<void>> localStorage_; std::unordered_map<uint64_t, std::shared_ptr<void>> localStorage_;
std::unordered_set<detail::EventBaseLocalBase*> localStorageToDtor_; std::unordered_set<detail::EventBaseLocalBaseBase*> localStorageToDtor_;
#endif
}; };
} // folly } // folly
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
* limitations under the License. * limitations under the License.
*/ */
#if !defined(ANDROID) && !defined(__ANDROID__) && !defined(__APPLE__)
#include <folly/io/async/EventBaseLocal.h> #include <folly/io/async/EventBaseLocal.h>
#include <atomic> #include <atomic>
#include <thread> #include <thread>
...@@ -98,5 +96,3 @@ void EventBaseLocalBase::setVoidUnlocked( ...@@ -98,5 +96,3 @@ void EventBaseLocalBase::setVoidUnlocked(
std::atomic<uint64_t> EventBaseLocalBase::keyCounter_{0}; std::atomic<uint64_t> EventBaseLocalBase::keyCounter_{0};
}} }}
#endif // !__ANDROID__ && !ANDROID && !__APPLE__
...@@ -16,8 +16,6 @@ ...@@ -16,8 +16,6 @@
#pragma once #pragma once
#if !defined(ANDROID) && !defined(__ANDROID__) && !defined(__APPLE__)
#include <boost/noncopyable.hpp> #include <boost/noncopyable.hpp>
#include <folly/Synchronized.h> #include <folly/Synchronized.h>
#include <folly/io/async/EventBase.h> #include <folly/io/async/EventBase.h>
...@@ -30,12 +28,12 @@ namespace folly { ...@@ -30,12 +28,12 @@ namespace folly {
namespace detail { namespace detail {
class EventBaseLocalBase : boost::noncopyable { class EventBaseLocalBase : public EventBaseLocalBaseBase, boost::noncopyable {
public: public:
EventBaseLocalBase() {} EventBaseLocalBase() {}
virtual ~EventBaseLocalBase(); virtual ~EventBaseLocalBase();
void erase(EventBase& evb); void erase(EventBase& evb);
void onEventBaseDestruction(EventBase& evb); void onEventBaseDestruction(EventBase& evb) override;
protected: protected:
void setVoid(EventBase& evb, std::shared_ptr<void>&& ptr); void setVoid(EventBase& evb, std::shared_ptr<void>&& ptr);
...@@ -128,5 +126,3 @@ class EventBaseLocal : public detail::EventBaseLocalBase { ...@@ -128,5 +126,3 @@ class EventBaseLocal : public detail::EventBaseLocalBase {
} }
#endif // !__ANDROID__ && !ANDROID && !__APPLE__
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment