Skip to content

Commit 85aab93

Browse files
work: WorkQueueBuilder: update to include work_timeout_ms member.
The k_work_q has been extended with a new feature, the work timeout, which comes with a new field to k_work_queue_config, work_timeout_ms, which must be initialized. Signed-off-by: Bjarki Arge Andreasen <[email protected]>
1 parent 1cab77b commit 85aab93

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

zephyr/src/work.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
//! .set_priority(2).
6464
//! .set_name(c"mainloop")
6565
//! .set_no_yield(true)
66+
//! .set_work_timeout_ms(1000)
6667
//! .start(MAIN_LOOP_STACK.init_once(()).unwrap())
6768
//! );
6869
//!
@@ -142,6 +143,7 @@ impl WorkQueueBuilder {
142143
name: ptr::null(),
143144
no_yield: false,
144145
essential: false,
146+
work_timeout_ms: 0,
145147
},
146148
priority: 0,
147149
}
@@ -177,6 +179,18 @@ impl WorkQueueBuilder {
177179
self
178180
}
179181

182+
/// Controls whether work queue monitors work timeouts.
183+
///
184+
/// If non-zero, and CONFIG_WORKQUEUE_WORK_TIMEOUT is enabled,
185+
/// the work queue will monitor the duration of each work item.
186+
/// If the work item handler takes longer than the specified
187+
/// time to execute, the work queue thread will be aborted, and
188+
/// an error will be logged if CONFIG_LOG is enabled.
189+
pub fn set_work_timeout_ms(&mut self, value: u32) -> &mut Self {
190+
self.config.work_timeout_ms = value;
191+
self
192+
}
193+
180194
/// Set the priority for the worker thread.
181195
///
182196
/// See the Zephyr docs for the meaning of priority.

0 commit comments

Comments
 (0)