<div dir="ltr"><div dir="ltr">Hi Laurent, thank you for the patch.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, May 24, 2021 at 11:58 AM Umang Jain <<a href="mailto:umang.jain@ideasonboard.com">umang.jain@ideasonboard.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Laurent<br>
<br>
Thanks for the patch<br>
<br>
On 5/23/21 8:01 AM, Laurent Pinchart wrote:<br>
> The Thread class is incorrectly documented as thread-safe, as the<br>
> dispatchMessages() function isn't thread-safe. Fix the documentation by<br>
> tagging individual functions as thread-safe as appropriate.<br>
><br>
> Signed-off-by: Laurent Pinchart <<a href="mailto:laurent.pinchart@ideasonboard.com" target="_blank">laurent.pinchart@ideasonboard.com</a>><br>
Reviewed-by: Umang Jain <<a href="mailto:umang.jain@ideasonboard.com" target="_blank">umang.jain@ideasonboard.com</a>><br></blockquote><div><br></div><div>Reviewed-by: Hirokazu Honda <<a href="mailto:hiroh@chromium.org">hiroh@chromium.org</a>></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> ---<br>
> src/libcamera/thread.cpp | 17 +++++++++++++++--<br>
> 1 file changed, 15 insertions(+), 2 deletions(-)<br>
><br>
> diff --git a/src/libcamera/thread.cpp b/src/libcamera/thread.cpp<br>
> index 198670de33a2..285b808332e8 100644<br>
> --- a/src/libcamera/thread.cpp<br>
> +++ b/src/libcamera/thread.cpp<br>
> @@ -229,8 +229,6 @@ ThreadData *ThreadData::current()<br>
> * called. The event loop dispatches events (messages, notifiers and timers)<br>
> * sent to the objects living in the thread. This behaviour can be modified by<br>
> * overriding the run() function.<br>
> - *<br>
> - * \context This class is \threadsafe.<br>
> */<br>
> <br>
> /**<br>
> @@ -361,6 +359,8 @@ void Thread::finishThread()<br>
> *<br>
> * Calling exit() on a thread that reimplements the run() method and doesn't<br>
> * call exec() will likely have no effect.<br>
> + *<br>
> + * \context This function is \threadsafe.<br>
> */<br>
> void Thread::exit(int code)<br>
> {<br>
> @@ -383,6 +383,8 @@ void Thread::exit(int code)<br>
> * utils::duration::max(), the wait never times out. If the thread is not<br>
> * running the function returns immediately.<br>
> *<br>
> + * \context This function is \threadsafe.<br>
> + *<br>
> * \return True if the thread has finished, or false if the wait timed out<br>
> */<br>
> bool Thread::wait(utils::duration duration)<br>
> @@ -412,6 +414,8 @@ bool Thread::wait(utils::duration duration)<br>
> * started. This method guarantees that it returns true after the start()<br>
> * method returns, and false after the wait() method returns.<br>
> *<br>
> + * \context This function is \threadsafe.<br>
> + *<br>
> * \return True if the thread is running, false otherwise<br>
> */<br>
> bool Thread::isRunning()<br>
> @@ -427,6 +431,7 @@ bool Thread::isRunning()<br>
> <br>
> /**<br>
> * \brief Retrieve the Thread instance for the current thread<br>
> + * \context This function is \threadsafe.<br>
> * \return The Thread instance for the current thread<br>
> */<br>
> Thread *Thread::current()<br>
> @@ -441,6 +446,8 @@ Thread *Thread::current()<br>
> * The thread ID corresponds to the Linux thread ID (TID) as returned by the<br>
> * gettid system call.<br>
> *<br>
> + * \context This function is \threadsafe.<br>
> + *<br>
> * \return The ID of the current thread<br>
> */<br>
> pid_t Thread::currentId()<br>
> @@ -455,6 +462,8 @@ pid_t Thread::currentId()<br>
> * This function retrieves the internal event dispatcher for the thread. The<br>
> * returned event dispatcher is valid until the thread is destroyed.<br>
> *<br>
> + * \context This function is \threadsafe.<br>
> + *<br>
> * \return Pointer to the event dispatcher<br>
> */<br>
> EventDispatcher *Thread::eventDispatcher()<br>
> @@ -544,6 +553,10 @@ void Thread::removeMessages(Object *receiver)<br>
> * This function immediately dispatches all the messages previously posted for<br>
> * this thread with postMessage() that match the message \a type. If the \a type<br>
> * is Message::Type::None, all messages are dispatched.<br>
> + *<br>
> + * Messages shall only be dispatched from the current thread, typically within<br>
> + * the thread from the run() function. Calling this function outside of the<br>
> + * thread results in undefined behaviour.<br>
> */<br>
> void Thread::dispatchMessages(Message::Type type)<br>
> {<br>
<br>
</blockquote></div></div>