Commit 6a1cf45e authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

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
parent 76ca3798
...@@ -46,16 +46,6 @@ class Executor { ...@@ -46,16 +46,6 @@ class Executor {
static const int8_t MID_PRI = 0; static const int8_t MID_PRI = 0;
static const int8_t HI_PRI = SCHAR_MAX; 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 { class KeepAlive {
public: public:
KeepAlive() {} KeepAlive() {}
......
...@@ -217,19 +217,6 @@ TEST(Executor, Runnable) { ...@@ -217,19 +217,6 @@ TEST(Executor, Runnable) {
EXPECT_EQ(counter, 1); 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) { TEST(Executor, ThrowableThen) {
InlineExecutor x; InlineExecutor x;
auto f = Future<Unit>().then([]() { throw std::runtime_error("Faildog"); }); auto f = Future<Unit>().then([]() { throw std::runtime_error("Faildog"); });
......
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