MCPcopy Create free account
hub / github.com/AlexInLog/ReactivePlusPlus / simulate_complex_scheduling

Function simulate_complex_scheduling

src/tests/rpp/test_scheduler.cpp:74–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74static std::string simulate_complex_scheduling(const auto& worker, const auto& obs, std::vector<std::string>& out)
75{
76 std::thread thread([&, worker] {
77 worker.schedule([&, worker](const auto&) {
78 out.push_back("Task 1 starts "s + get_thread_id_as_string());
79
80 worker.schedule([&, worker](const auto&, int& counter) -> rpp::schedulers::optional_delay_from_now {
81 out.push_back("Task 2 starts "s + get_thread_id_as_string());
82
83 worker.schedule([&](const auto&) {
84 out.push_back("Task 4 runs "s + get_thread_id_as_string());
85 return rpp::schedulers::optional_delay_from_now{};
86 },
87 obs);
88
89 out.push_back("Task 2 ends "s + get_thread_id_as_string());
90 if (counter++ < 1)
91 return rpp::schedulers::optional_delay_from_now{std::chrono::nanoseconds{1}};
92 return std::nullopt;
93 },
94 obs,
95 int{});
96
97 worker.schedule([&](const auto&, int& counter) -> rpp::schedulers::optional_delay_from_now {
98 out.push_back("Task 3 starts "s + get_thread_id_as_string());
99
100 out.push_back("Task 3 ends "s + get_thread_id_as_string());
101 if (counter++ < 1)
102 return rpp::schedulers::optional_delay_from_now{std::chrono::nanoseconds{1}};
103 return std::nullopt;
104 },
105 obs,
106 int{});
107
108 out.push_back("Task 1 ends "s + get_thread_id_as_string());
109 return rpp::schedulers::optional_delay_from_now{};
110 },
111 obs);
112 });
113
114 auto threadid = get_thread_id_as_string(thread.get_id());
115 thread.join();
116 return threadid;
117}
118
119static std::string simulate_complex_scheduling_with_delay(const auto& worker, const auto& obs, std::vector<std::string>& out)
120{

Callers 1

test_scheduler.cppFile · 0.85

Calls 3

get_thread_id_as_stringFunction · 0.85
scheduleMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected