From 7744f15ecfc43c0f19b707e0c7db5f92ffb8986a Mon Sep 17 00:00:00 2001 From: Bjarki Arge Andreasen Date: Fri, 11 Apr 2025 09:07:57 +0200 Subject: [PATCH] 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 --- zephyr/src/work.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/zephyr/src/work.rs b/zephyr/src/work.rs index c3ed8d2..7617932 100644 --- a/zephyr/src/work.rs +++ b/zephyr/src/work.rs @@ -63,6 +63,7 @@ //! .set_priority(2). //! .set_name(c"mainloop") //! .set_no_yield(true) +//! .set_work_timeout_ms(1000) //! .start(MAIN_LOOP_STACK.init_once(()).unwrap()) //! ); //! @@ -142,6 +143,7 @@ impl WorkQueueBuilder { name: ptr::null(), no_yield: false, essential: false, + work_timeout_ms: 0, }, priority: 0, } @@ -177,6 +179,18 @@ impl WorkQueueBuilder { self } + /// Controls whether work queue monitors work timeouts. + /// + /// If non-zero, and CONFIG_WORKQUEUE_WORK_TIMEOUT is enabled, + /// the work queue will monitor the duration of each work item. + /// If the work item handler takes longer than the specified + /// time to execute, the work queue thread will be aborted, and + /// an error will be logged if CONFIG_LOG is enabled. + pub fn set_work_timeout_ms(&mut self, value: u32) -> &mut Self { + self.config.work_timeout_ms = value; + self + } + /// Set the priority for the worker thread. /// /// See the Zephyr docs for the meaning of priority.