Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/include/cpputils2/linux/thread/thread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ namespace CppUtils2
}
};

struct DeadLineThreadConfig : public ThreadConfig
{
DeadLineThreadConfig()
{
policy = SCHED_DEADLINE;
priority = 0;
}
};

Result set_thread_sched_policy(std::thread &thread, const int policy, const int priority)
{
struct sched_param param;
Expand Down
7 changes: 7 additions & 0 deletions src/test/cpputils2_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,18 @@ namespace
TEST(ThreadMng, ThreadMng)
{
CppUtils2::BestEffortThreadConfig config;

std::thread t([&config]() {

});
auto ret = CppUtils2::set_thread_sched_policy(t, config);
EXPECT_EQ(ret, CppUtils2::Result::RET_OK);

auto exp_config = CppUtils2::get_thread_sched_policy(t);
EXPECT_TRUE(exp_config.has_value());
EXPECT_EQ(exp_config.value().policy, config.policy);
EXPECT_EQ(exp_config.value().priority, config.priority);

t.join();
}

Expand Down
Loading