From 70238ceca5b2f0be1330ecb9664ae0f59f151152 Mon Sep 17 00:00:00 2001 From: Kieran Bingham Date: Tue, 23 Mar 2021 13:55:09 +0000 Subject: utils: ipc: proxy: Track IPA with a state machine Asynchronous tasks can only be submitted while the IPA is running. Further more, the shutdown sequence can not be tracked with a simple running flag. We can also be in the state 'Stopping' where we have not yet completed all events, but we must not commence anything new. Refactor the running_ boolean into a stateful enum to track this. Reviewed-by: Paul Elder Reviewed-by: Laurent Pinchart Signed-off-by: Kieran Bingham --- utils/ipc/generators/libcamera_templates/proxy_functions.tmpl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'utils/ipc/generators/libcamera_templates/proxy_functions.tmpl') diff --git a/utils/ipc/generators/libcamera_templates/proxy_functions.tmpl b/utils/ipc/generators/libcamera_templates/proxy_functions.tmpl index 8addc2fa..ea9cc86b 100644 --- a/utils/ipc/generators/libcamera_templates/proxy_functions.tmpl +++ b/utils/ipc/generators/libcamera_templates/proxy_functions.tmpl @@ -23,9 +23,12 @@ # \brief Generate function body for IPA stop() function for thread #} {%- macro stop_thread_body() -%} - if (!running_) + ASSERT(state_ != ProxyStopping); + if (state_ != ProxyRunning) return; + state_ = ProxyStopping; + proxy_.invokeMethod(&ThreadProxy::stop, ConnectionTypeBlocking); thread_.exit(); @@ -33,7 +36,7 @@ Thread::current()->dispatchMessages(Message::Type::InvokeMessage); - running_ = false; + state_ = ProxyStopped; {%- endmacro -%} -- cgit v1.2.1