Skip to content

Commit 5fc831d

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 d4f9036 commit 5fc831d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

zephyr/src/work.rs

+14
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
//! .set_priority(2).
139139
//! .set_name(c"mainloop")
140140
//! .set_no_yield(true)
141+
//! .set_work_timeout_ms(1000)
141142
//! .start(MAIN_LOOP_STACK.init_once(()).unwrap())
142143
//! );
143144
//!
@@ -220,6 +221,7 @@ impl WorkQueueBuilder {
220221
name: ptr::null(),
221222
no_yield: false,
222223
essential: false,
224+
work_timeout_ms: 0,
223225
},
224226
priority: 0,
225227
}
@@ -255,6 +257,18 @@ impl WorkQueueBuilder {
255257
self
256258
}
257259

260+
/// Controls whether work queue monitors work timeouts.
261+
///
262+
/// If non-zero, and CONFIG_WORKQUEUE_WORK_TIMEOUT is enabled,
263+
/// the work queue will monitor the duration of each work item.
264+
/// If the work item handler takes longer than the specified
265+
/// time to execute, the work queue thread will be aborted, and
266+
/// an error will be logged if CONFIG_LOG is enabled.
267+
pub fn set_work_timeout_ms(&mut self, value: u32) -> &mut Self {
268+
self.config.work_timeout_ms = value;
269+
self
270+
}
271+
258272
/// Set the priority for the worker thread.
259273
///
260274
/// See the Zephyr docs for the meaning of priority.

0 commit comments

Comments
 (0)