#include #include #include "pls/pls.h" constexpr int MAX_NUM_TASKS = 32; constexpr int MAX_STACK_SIZE = 1024 * 8; TEST_CASE("spawn/sync invoke calls correctly", "[algorithms/invoke.h]") { pls::scheduler scheduler{3, MAX_NUM_TASKS, MAX_STACK_SIZE}; std::atomic num_run{0}; scheduler.perform_work([&] { pls::spawn([&] { num_run++; while (num_run < 3); }); pls::spawn([&] { while (num_run < 1); num_run++; while (num_run < 3); }); pls::spawn([&] { while (num_run < 2); num_run++; }); pls::sync(); REQUIRE(num_run == 3); }); } TEST_CASE("parallel invoke calls correctly", "[algorithms/invoke.h]") { pls::scheduler scheduler{3, MAX_NUM_TASKS, MAX_STACK_SIZE}; std::atomic num_run{0}; scheduler.perform_work([&] { pls::invoke([&] { num_run++; while (num_run < 3); }, [&] { while (num_run < 1); num_run++; while (num_run < 3); }, [&] { while (num_run < 2); num_run++; }); REQUIRE(num_run == 3); }); }