Skip to content

Commit 0d66fd1

Browse files
work: update to include new workq config param
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. This commit adds the parameter to the WorkQueueBuilder builder. Signed-off-by: Bjarki Arge Andreasen <[email protected]>
1 parent 8952b44 commit 0d66fd1

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
//!
@@ -225,6 +226,7 @@ impl WorkQueueBuilder {
225226
name: ptr::null(),
226227
no_yield: false,
227228
essential: false,
229+
work_timeout_ms: 0,
228230
},
229231
priority: 0,
230232
}
@@ -260,6 +262,18 @@ impl WorkQueueBuilder {
260262
self
261263
}
262264

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

0 commit comments

Comments
 (0)