29 auto cpuExecutor = std::make_shared<CPUThreadPoolExecutor>(4);
33 std::atomic<size_t> nextCallIndex{0};
34 std::atomic<bool> result{
true};
36 auto joinPromise = std::make_shared<std::promise<void>>();
37 auto joinFuture = joinPromise->get_future();
39 constexpr
size_t kNumCalls = 10000;
40 for (
size_t callIndex = 0; callIndex < kNumCalls; ++callIndex) {
41 producer->add([&result, &executor, &nextCallIndex, callIndex, joinPromise] {
42 executor.
add([&result, &nextCallIndex, callIndex, joinPromise] {
43 if (nextCallIndex != callIndex) {
47 if (nextCallIndex.exchange(callIndex + 1) != callIndex) {
74 auto cpuExecutor = std::make_shared<CPUThreadPoolExecutor>(4);
EventBase * getEventBase()
bool isSequencedExecutor(folly::Executor &executor)
—— Concurrent Priority Queue Implementation ——
static KeepAlive< SerialExecutor > create(KeepAlive< Executor > parent=getKeepAliveToken(getCPUExecutor().get()))
PUSHMI_INLINE_VAR constexpr __adl::get_executor_fn executor
void testExecutor(folly::Executor &executor)
static KeepAlive< ExecutorT > getKeepAliveToken(ExecutorT *executor)
#define EXPECT_TRUE(condition)
#define EXPECT_FALSE(condition)
TEST(SequencedExecutor, CPUThreadPoolExecutor)