10 #include <gtest/gtest.h>
11 #include <task_manager.hpp>
17 static void test_task_function(
void *arg) {
18 auto val =
static_cast<uint8_t *
>(arg);
22 static void test_task_function2(
void *arg) {
23 auto val =
static_cast<uint8_t *
>(arg);
24 std::this_thread::sleep_for(std::chrono::milliseconds(500));
31 uint8_t test_value = 10;
36 ASSERT_EQ(test_value, 11);
42 uint8_t test_value = 10;
49 ASSERT_EQ(test_value, 12);
55 uint8_t test_value = 10;
61 std::this_thread::sleep_for(std::chrono::milliseconds(500));
62 ASSERT_EQ(test_value, 11);
68 uint8_t test_value = 10;
74 std::this_thread::sleep_for(std::chrono::seconds(2));
75 ASSERT_EQ(test_value, 12);
83 uint8_t test_value1 = 10;
84 uint8_t test_value2 = 20;
87 auto start = std::chrono::duration_cast<std::chrono::milliseconds>(
88 std::chrono::high_resolution_clock::now().time_since_epoch());
95 auto end = std::chrono::duration_cast<std::chrono::milliseconds>(
96 std::chrono::high_resolution_clock::now().time_since_epoch());
98 ASSERT_NEAR(
static_cast<double>(end.count() - start.count()), 515, 200);
99 ASSERT_EQ(test_value1, 11);
100 ASSERT_EQ(test_value2, 21);
103 INSTANTIATE_TEST_CASE_P(test_do_work_while_waiting,
task_manager_tests, ::testing::Range(0, 15));
105 int main(
int argc,
char **argv) {
106 ::testing::InitGoogleTest(&argc, argv);
107 return RUN_ALL_TESTS();
An object representing a task to be run by the task manager.
The Task Manager handles all things multi-threaded in the engine.
void start_task_lockfree(ST::task *arg)
void wait_for_task(task_id id)
void work_wait_for_task(task_id id)
task_id start_task(ST::task *arg)