#include <folly/executors/GlobalExecutor.h>
#include <memory>
#include <thread>
#include <folly/Function.h>
#include <folly/SharedMutex.h>
#include <folly/Singleton.h>
#include <folly/detail/AsyncTrace.h>
#include <folly/executors/CPUThreadPoolExecutor.h>
#include <folly/executors/IOExecutor.h>
#include <folly/executors/IOThreadPoolExecutor.h>
#include <folly/executors/InlineExecutor.h>
#include <folly/system/HardwareConcurrency.h>
usingnamespacefolly;
FOLLY_GFLAGS_DEFINE_uint32(…);
FOLLY_GFLAGS_DEFINE_uint32(…);
FOLLY_GFLAGS_DEFINE_bool(…);
FOLLY_GFLAGS_DEFINE_uint32(…);
namespace {
ImmutableGlobalCPUExecutor;
class GlobalTag { … };
class DefaultCPUExecutor : public InlineLikeExecutor { … };
Singleton<std::shared_ptr<DefaultCPUExecutor>> gDefaultGlobalCPUExecutor([] { … });
Singleton<std::shared_ptr<ImmutableGlobalCPUExecutor>, GlobalTag>
gImmutableGlobalCPUExecutor([] { … });
Singleton<std::shared_ptr<IOThreadPoolExecutor>, GlobalTag>
gImmutableGlobalIOExecutor([] { … });
template <class ExecutorBase>
std::shared_ptr<ExecutorBase> getImmutable();
template <>
std::shared_ptr<Executor> getImmutable() { … }
template <>
std::shared_ptr<IOExecutor> getImmutable() { … }
template <class ExecutorBase>
class GlobalExecutor { … };
LeakySingleton<GlobalExecutor<Executor>> gGlobalCPUExecutor([] { … });
LeakySingleton<GlobalExecutor<IOExecutor>> gGlobalIOExecutor([] { … });
}
namespace folly {
namespace detail {
std::shared_ptr<Executor> tryGetImmutableCPUPtr() { … }
}
Executor::KeepAlive<> getGlobalCPUExecutor() { … }
Executor::KeepAlive<> getGlobalCPUExecutorWeakRef() { … }
GlobalCPUExecutorCounters getGlobalCPUExecutorCounters() { … }
Executor::KeepAlive<IOExecutor> getGlobalIOExecutor() { … }
std::shared_ptr<Executor> getUnsafeMutableGlobalCPUExecutor() { … }
std::shared_ptr<Executor> getCPUExecutor() { … }
void setUnsafeMutableGlobalCPUExecutorToGlobalCPUExecutor() { … }
void setCPUExecutorToGlobalCPUExecutor() { … }
void setUnsafeMutableGlobalCPUExecutor(std::weak_ptr<Executor> executor) { … }
void setCPUExecutor(std::weak_ptr<Executor> executor) { … }
std::shared_ptr<IOExecutor> getUnsafeMutableGlobalIOExecutor() { … }
std::shared_ptr<IOExecutor> getIOExecutor() { … }
void setUnsafeMutableGlobalIOExecutor(std::weak_ptr<IOExecutor> executor) { … }
void setIOExecutor(std::weak_ptr<IOExecutor> executor) { … }
EventBase* getUnsafeMutableGlobalEventBase() { … }
EventBase* getEventBase() { … }
}