Skip to content

Commit ee7d7a1

Browse files
authored
Merge pull request #6 from yangosoft/feature/thread-utils
More test
2 parents 486a87e + a0f434c commit ee7d7a1

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/include/cpputils2/linux/thread/thread.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ namespace CppUtils2
4444
}
4545
};
4646

47+
struct DeadLineThreadConfig : public ThreadConfig
48+
{
49+
DeadLineThreadConfig()
50+
{
51+
policy = SCHED_DEADLINE;
52+
priority = 0;
53+
}
54+
};
55+
4756
Result set_thread_sched_policy(std::thread &thread, const int policy, const int priority)
4857
{
4958
struct sched_param param;

src/test/cpputils2_tests.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,18 @@ namespace
147147
TEST(ThreadMng, ThreadMng)
148148
{
149149
CppUtils2::BestEffortThreadConfig config;
150+
150151
std::thread t([&config]() {
151152

152153
});
153154
auto ret = CppUtils2::set_thread_sched_policy(t, config);
154155
EXPECT_EQ(ret, CppUtils2::Result::RET_OK);
156+
157+
auto exp_config = CppUtils2::get_thread_sched_policy(t);
158+
EXPECT_TRUE(exp_config.has_value());
159+
EXPECT_EQ(exp_config.value().policy, config.policy);
160+
EXPECT_EQ(exp_config.value().priority, config.priority);
161+
155162
t.join();
156163
}
157164

0 commit comments

Comments
 (0)