50 using namespace std::chrono;
68 auto poll_helper = [](
bool do_fifo) noexcept {
74 wait_fifo.push_back(&wait_msg);
80 auto t =
zpp::thread(test_thread, test_thread_stack(), attr, poll_helper,
true);
82 auto rc = wait_events.try_poll_for(1s);
86 zassert_equal(rc,
true,
"");
88 zassert_equal(wait_events[0].is_ready(),
true,
"");
89 zassert_equal(wait_sem.try_take(),
true,
"");
91 zassert_equal(wait_events[1].is_ready(),
true,
"");
92 auto msg_ptr = wait_fifo.try_pop_front();
93 zassert_not_null(msg_ptr,
"");
94 zassert_equal(msg_ptr, &wait_msg,
"");
97 zassert_equal(wait_events[2].is_ready(),
true,
"");
98 zassert_equal(wait_signal.check().value_or(-1),
SIGNAL_RESULT,
"");
100 zassert_equal(wait_events[3].is_ready(),
false,
"");
105 wait_events[0].reset();
106 wait_events[1].reset();
107 wait_events[2].reset();
108 wait_events[3].reset();
111 zassert_equal(wait_events.try_poll_for(1s),
false,
"");
113 zassert_equal(wait_events[0].is_ready(),
false,
"");
114 zassert_equal(wait_events[1].is_ready(),
false,
"");
115 zassert_equal(wait_events[2].is_ready(),
false,
"");
116 zassert_equal(wait_events[3].is_ready(),
false,
"");
124 attr.set(old_prio + 1);
125 t =
zpp::thread(test_thread, test_thread_stack(), attr, poll_helper,
false);
127 rc = wait_events.try_poll_for(1s);
131 zassert_equal(rc,
true,
"");
133 zassert_equal(wait_events[0].is_ready(),
true,
"");
134 zassert_equal(wait_sem.try_take(),
true,
"");
136 zassert_equal(wait_events[1].is_ready(),
false,
"");
137 msg_ptr = wait_fifo.try_pop_front();
138 zassert_is_null(msg_ptr,
"");
140 zassert_equal(wait_events[2].is_ready(),
true,
"");
141 zassert_equal(wait_signal.check().value_or(-1),
SIGNAL_RESULT,
"");
143 zassert_equal(wait_events[3].is_ready(),
false,
"");
150 wait_events[0].reset();
151 wait_events[1].reset();
152 wait_events[2].reset();
153 wait_events[3].reset();
156 attr.set(old_prio - 1);
157 t =
zpp::thread(test_thread, test_thread_stack(), attr, poll_helper,
true);
162 rc = wait_events.try_poll_for(1s);
164 zassert_equal(rc,
true,
"");
166 zassert_equal(wait_events[0].is_ready(),
true,
"");
167 zassert_equal(wait_sem.try_take(),
true,
"");
169 zassert_equal(wait_events[1].is_ready(),
false,
"");
170 msg_ptr = wait_fifo.try_pop_front();
171 zassert_is_null(msg_ptr,
"");
173 zassert_equal(wait_events[2].is_ready(),
false,
"");
175 wait_events[0].reset();
180 rc = wait_events.try_poll_for(1s);
182 zassert_equal(rc,
true,
"");
184 zassert_equal(wait_events[0].is_ready(),
false,
"");
185 zassert_equal(wait_sem.try_take(),
false,
"");
187 zassert_equal(wait_events[1].is_ready(),
true,
"");
188 msg_ptr = wait_fifo.try_pop_front();
189 zassert_not_null(msg_ptr,
"");
191 zassert_equal(wait_events[2].is_ready(),
false,
"");
193 wait_events[1].reset();
198 rc = wait_events.try_poll_for(1s);
200 zassert_equal(rc,
true,
"");
202 zassert_equal(wait_events[0].is_ready(),
false,
"");
203 zassert_equal(wait_sem.try_take(),
false,
"");
205 zassert_equal(wait_events[1].is_ready(),
false,
"");
206 msg_ptr = wait_fifo.try_pop_front();
207 zassert_is_null(msg_ptr,
"");
209 zassert_equal(wait_events[2].is_ready(),
true,
"");
210 zassert_equal(wait_signal.check().value_or(-1),
SIGNAL_RESULT,
"");
212 wait_events[2].reset();
Thread creation attributes.
The class thread repecents a single Zephyr thread.
void set_priority(thread_prio prio) noexcept
Set the current thread's priority.
auto sleep_for(const std::chrono::duration< T_Rep, T_Period > &sleep_duration)
Suspend the current thread for a specified time duration.
thread_prio get_priority() noexcept
Get the current thread's priority.