30 std::this_thread::sleep_for(milliseconds(ms));
39 std::vector<int> expected;
41 for (
int i = 0;
i < 20; ++
i) {
48 expected.push_back(
i);
53 executor->add([&finished_baton] { finished_baton.
post(); });
54 finished_baton.
wait();
60 SimpleTest(std::make_shared<folly::CPUThreadPoolExecutor>(4));
63 SimpleTest(std::make_shared<folly::InlineExecutor>());
70 auto cpu_executor = std::make_shared<folly::CPUThreadPoolExecutor>(4);
76 executor->add([&start_baton] { start_baton.
wait(); });
79 std::vector<int> expected;
81 for (
int i = 0;
i < 20; ++
i) {
82 executor->add([
i, &values] {
88 expected.push_back(
i);
92 executor->add([&finished_baton] { finished_baton.
post(); });
101 finished_baton.
wait();
113 std::vector<int> expected = {{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}};
116 std::function<void()> lambda = [&] {
129 finished_baton.
post();
139 finished_baton.
wait();
152 auto executor = SerialExecutor::create();
void RecursiveAddTest(std::shared_ptr< folly::Executor > const &parent)
#define EXPECT_EQ(val1, val2)
PUSHMI_INLINE_VAR constexpr __adl::get_executor_fn executor
TEST(SerialExecutor, Simple)
FOLLY_ALWAYS_INLINE void wait(const WaitOptions &opt=wait_options()) noexcept
void SimpleTest(std::shared_ptr< folly::Executor > const &parent)
static Func burnMs(uint64_t ms)
Executor that guarantees serial non-concurrent execution of added tasks.
Executor::KeepAlive< ExecutorT > getKeepAliveToken(ExecutorT *executor)
folly::Function< void()> parent
std::vector< int > values(1'000)