Commit dff3d40c authored by Andrii Grynenko's avatar Andrii Grynenko Committed by Facebook GitHub Bot

InlineLikeExecutor

Summary: Tag all inline-like executors, so that there's a single way to detect them in places where we don't want inline executors.

Differential Revision: D26564118

fbshipit-source-id: 1a55c03bee0a0a56328175c016d3880a86eab8b1
parent 0bdb2b67
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <folly/executors/CPUThreadPoolExecutor.h> #include <folly/executors/CPUThreadPoolExecutor.h>
#include <folly/executors/IOExecutor.h> #include <folly/executors/IOExecutor.h>
#include <folly/executors/IOThreadPoolExecutor.h> #include <folly/executors/IOThreadPoolExecutor.h>
#include <folly/executors/InlineExecutor.h>
#include <folly/system/HardwareConcurrency.h> #include <folly/system/HardwareConcurrency.h>
using namespace folly; using namespace folly;
...@@ -35,7 +36,7 @@ namespace { ...@@ -35,7 +36,7 @@ namespace {
class GlobalTag {}; class GlobalTag {};
// aka InlineExecutor // aka InlineExecutor
class DefaultCPUExecutor : public Executor { class DefaultCPUExecutor : public InlineLikeExecutor {
public: public:
FOLLY_NOINLINE void add(Func f) override { f(); } FOLLY_NOINLINE void add(Func f) override { f(); }
}; };
...@@ -138,9 +139,6 @@ namespace detail { ...@@ -138,9 +139,6 @@ namespace detail {
std::shared_ptr<Executor> tryGetImmutableCPUPtr() { std::shared_ptr<Executor> tryGetImmutableCPUPtr() {
return getImmutable<Executor>(); return getImmutable<Executor>();
} }
bool isDefaultExecutor(Executor* ex) {
return dynamic_cast<DefaultCPUExecutor*>(ex);
}
} // namespace detail } // namespace detail
Executor::KeepAlive<> getGlobalCPUExecutor() { Executor::KeepAlive<> getGlobalCPUExecutor() {
......
...@@ -25,7 +25,6 @@ namespace folly { ...@@ -25,7 +25,6 @@ namespace folly {
namespace detail { namespace detail {
std::shared_ptr<Executor> tryGetImmutableCPUPtr(); std::shared_ptr<Executor> tryGetImmutableCPUPtr();
bool isDefaultExecutor(Executor*);
} // namespace detail } // namespace detail
/** /**
......
...@@ -24,10 +24,15 @@ ...@@ -24,10 +24,15 @@
namespace folly { namespace folly {
class InlineLikeExecutor : public virtual Executor {
public:
virtual ~InlineLikeExecutor() {}
};
/// When work is "queued", execute it immediately inline. /// When work is "queued", execute it immediately inline.
/// Usually when you think you want this, you actually want a /// Usually when you think you want this, you actually want a
/// QueuedImmediateExecutor. /// QueuedImmediateExecutor.
class InlineExecutor : public Executor { class InlineExecutor : public InlineLikeExecutor {
public: public:
FOLLY_ERASE static InlineExecutor& instance() noexcept { FOLLY_ERASE static InlineExecutor& instance() noexcept {
auto const value = cache.load(std::memory_order_acquire); auto const value = cache.load(std::memory_order_acquire);
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <folly/Executor.h> #include <folly/Executor.h>
#include <folly/ThreadLocal.h> #include <folly/ThreadLocal.h>
#include <folly/executors/InlineExecutor.h>
namespace folly { namespace folly {
...@@ -28,7 +29,7 @@ namespace folly { ...@@ -28,7 +29,7 @@ namespace folly {
* to this executor by one of its own callbacks will be queued instead of * to this executor by one of its own callbacks will be queued instead of
* executed inline (nested). This is usually better behavior than Inline. * executed inline (nested). This is usually better behavior than Inline.
*/ */
class QueuedImmediateExecutor : public Executor { class QueuedImmediateExecutor : public InlineLikeExecutor {
public: public:
static QueuedImmediateExecutor& instance(); static QueuedImmediateExecutor& instance();
......
...@@ -35,8 +35,6 @@ ...@@ -35,8 +35,6 @@
namespace folly { namespace folly {
class InlineExecutor;
namespace coro { namespace coro {
namespace detail { namespace detail {
......
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