From: Yedidya Feldblum Date: Fri, 6 Oct 2017 18:45:18 +0000 (-0700) Subject: Remove Executor::addPtr X-Git-Tag: v2017.10.09.00~3 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=6a1cf45e75937ac4ab2b714556cc62fb8d788811;p=folly.git Remove Executor::addPtr 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 --- diff --git a/folly/Executor.h b/folly/Executor.h index 65268dfe..d4a190a6 100644 --- a/folly/Executor.h +++ b/folly/Executor.h @@ -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 - void addPtr(P fn) { - this->add([fn]() mutable { (*fn)(); }); - } - class KeepAlive { public: KeepAlive() {} diff --git a/folly/futures/test/ExecutorTest.cpp b/folly/futures/test/ExecutorTest.cpp index 67514872..88679ecb 100644 --- a/folly/futures/test/ExecutorTest.cpp +++ b/folly/futures/test/ExecutorTest.cpp @@ -217,19 +217,6 @@ TEST(Executor, Runnable) { EXPECT_EQ(counter, 1); } -TEST(Executor, RunnablePtr) { - InlineExecutor x; - struct Runnable { - std::function fn; - void operator()() { fn(); } - }; - size_t counter = 0; - auto fnp = std::make_shared(); - fnp->fn = [&]{ counter++; }; - x.addPtr(fnp); - EXPECT_EQ(counter, 1); -} - TEST(Executor, ThrowableThen) { InlineExecutor x; auto f = Future().then([]() { throw std::runtime_error("Faildog"); });