Remove Executor::addPtr
authorYedidya Feldblum <yfeldblum@fb.com>
Fri, 6 Oct 2017 18:45:18 +0000 (11:45 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Fri, 6 Oct 2017 18:59:08 +0000 (11:59 -0700)
Summary:
[Folly] Remove `Executor::addPtr`.

It was there to support passing non-copyable callable objects wrapped as `std::shared_ptr`. It is no longer useful since we have `Function`, which is a non-copyable version of `std::function` which can support capturing non-copyable objects, and it is generally unused.

Reviewed By: spacedentist

Differential Revision: D5983801

fbshipit-source-id: b49a86f8dd7e5250a097b0e714a1bdf9ac362916

folly/Executor.h
folly/futures/test/ExecutorTest.cpp

index 65268dfe2b5af3e653b59b4ac074c7cc35e75db7..d4a190a6c1934f245abde5ff517f997fb6330399 100644 (file)
@@ -46,16 +46,6 @@ class Executor {
   static const int8_t MID_PRI = 0;
   static const int8_t HI_PRI  = SCHAR_MAX;
 
-  /// A convenience function for shared_ptr to legacy functors.
-  ///
-  /// Sometimes you have a functor that is move-only, and therefore can't be
-  /// converted to a std::function (e.g. std::packaged_task). In that case,
-  /// wrap it in a shared_ptr (or maybe folly::MoveWrapper) and use this.
-  template <class P>
-  void addPtr(P fn) {
-    this->add([fn]() mutable { (*fn)(); });
-  }
-
   class KeepAlive {
    public:
     KeepAlive() {}
index 6751487206cc36606bdff2f02ab90e550aaea4eb..88679ecba6284cb9ca378ff444cc5f2588ecafb1 100644 (file)
@@ -217,19 +217,6 @@ TEST(Executor, Runnable) {
   EXPECT_EQ(counter, 1);
 }
 
-TEST(Executor, RunnablePtr) {
-  InlineExecutor x;
-  struct Runnable {
-    std::function<void()> fn;
-    void operator()() { fn(); }
-  };
-  size_t counter = 0;
-  auto fnp = std::make_shared<Runnable>();
-  fnp->fn = [&]{ counter++; };
-  x.addPtr(fnp);
-  EXPECT_EQ(counter, 1);
-}
-
 TEST(Executor, ThrowableThen) {
   InlineExecutor x;
   auto f = Future<Unit>().then([]() { throw std::runtime_error("Faildog"); });