[{"id":17126,"web_url":"https://patchwork.libcamera.org/comment/17126/","msgid":"<YKn4pRVoHlzUpwq8@oden.dyn.berto.se>","date":"2021-05-23T06:39:33","subject":"Re: [libcamera-devel] [PATCH 1/4] libcamera: thread: Document\n\tdispatchMessages() thread-safety requirements","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your work.\n\nOn 2021-05-23 05:31:52 +0300, Laurent Pinchart wrote:\n> The Thread class is incorrectly documented as thread-safe, as the\n> dispatchMessages() function isn't thread-safe. Fix the documentation by\n> tagging individual functions as thread-safe as appropriate.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  src/libcamera/thread.cpp | 17 +++++++++++++++--\n>  1 file changed, 15 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/libcamera/thread.cpp b/src/libcamera/thread.cpp\n> index 198670de33a2..285b808332e8 100644\n> --- a/src/libcamera/thread.cpp\n> +++ b/src/libcamera/thread.cpp\n> @@ -229,8 +229,6 @@ ThreadData *ThreadData::current()\n>   * called. The event loop dispatches events (messages, notifiers and timers)\n>   * sent to the objects living in the thread. This behaviour can be modified by\n>   * overriding the run() function.\n> - *\n> - * \\context This class is \\threadsafe.\n>   */\n>  \n>  /**\n> @@ -361,6 +359,8 @@ void Thread::finishThread()\n>   *\n>   * Calling exit() on a thread that reimplements the run() method and doesn't\n>   * call exec() will likely have no effect.\n> + *\n> + * \\context This function is \\threadsafe.\n>   */\n>  void Thread::exit(int code)\n>  {\n> @@ -383,6 +383,8 @@ void Thread::exit(int code)\n>   * utils::duration::max(), the wait never times out. If the thread is not\n>   * running the function returns immediately.\n>   *\n> + * \\context This function is \\threadsafe.\n> + *\n>   * \\return True if the thread has finished, or false if the wait timed out\n>   */\n>  bool Thread::wait(utils::duration duration)\n> @@ -412,6 +414,8 @@ bool Thread::wait(utils::duration duration)\n>   * started. This method guarantees that it returns true after the start()\n>   * method returns, and false after the wait() method returns.\n>   *\n> + * \\context This function is \\threadsafe.\n> + *\n>   * \\return True if the thread is running, false otherwise\n>   */\n>  bool Thread::isRunning()\n> @@ -427,6 +431,7 @@ bool Thread::isRunning()\n>  \n>  /**\n>   * \\brief Retrieve the Thread instance for the current thread\n> + * \\context This function is \\threadsafe.\n>   * \\return The Thread instance for the current thread\n>   */\n>  Thread *Thread::current()\n> @@ -441,6 +446,8 @@ Thread *Thread::current()\n>   * The thread ID corresponds to the Linux thread ID (TID) as returned by the\n>   * gettid system call.\n>   *\n> + * \\context This function is \\threadsafe.\n> + *\n>   * \\return The ID of the current thread\n>   */\n>  pid_t Thread::currentId()\n> @@ -455,6 +462,8 @@ pid_t Thread::currentId()\n>   * This function retrieves the internal event dispatcher for the thread. The\n>   * returned event dispatcher is valid until the thread is destroyed.\n>   *\n> + * \\context This function is \\threadsafe.\n> + *\n>   * \\return Pointer to the event dispatcher\n>   */\n>  EventDispatcher *Thread::eventDispatcher()\n> @@ -544,6 +553,10 @@ void Thread::removeMessages(Object *receiver)\n>   * This function immediately dispatches all the messages previously posted for\n>   * this thread with postMessage() that match the message \\a type. If the \\a type\n>   * is Message::Type::None, all messages are dispatched.\n> + *\n> + * Messages shall only be dispatched from the current thread, typically within\n> + * the thread from the run() function. Calling this function outside of the\n> + * thread results in undefined behaviour.\n>   */\n>  void Thread::dispatchMessages(Message::Type type)\n>  {\n> -- \n> Regards,\n> \n> Laurent Pinchart\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 28F96C3201\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 23 May 2021 06:39:38 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8B2606891A;\n\tSun, 23 May 2021 08:39:37 +0200 (CEST)","from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com\n\t[IPv6:2a00:1450:4864:20::22d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EAC2A602AE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 23 May 2021 08:39:35 +0200 (CEST)","by mail-lj1-x22d.google.com with SMTP id f12so29235255ljp.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 22 May 2021 23:39:35 -0700 (PDT)","from localhost (h-155-4-209-203.A463.priv.bahnhof.se.\n\t[155.4.209.203]) by smtp.gmail.com with ESMTPSA id\n\tx207sm1087194lff.234.2021.05.22.23.39.34\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSat, 22 May 2021 23:39:34 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com\n\theader.b=\"Nhy+sJq+\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=l0QgjfwNFuFrInPAg67q2icejFWSxCvplBbvF8tE6cA=;\n\tb=Nhy+sJq+fiB7yay8s1I5ExikHj7AGgfDcCea5ESR7G6vP1mbX43q2EmAEPHPaUc/uT\n\tZDEvTxeaStspKBQC6nBIxZo6ZUke0S3x1nrQ55ZuBpBVmJjyqP/eYJ8WfNB826bqxlPb\n\tzNjpRc+Lw2hwsevd3EWou5MR4iqc+plAmarMr9hYoyGOgw26MNU4VpbTHkbACgHDoWd9\n\t+/cyC5m6g+ETyg30QzBEa19IuilOowNGRi9umMTV8lzlHK/k2GywEFt90zHpi5uFjrIR\n\tNqN2LH8jAv+qJKfNxxSJ1UeJGYFCo+RKy3k2oTP7XXosJYxedyH6Cib9uMR7OmyP3gRW\n\t6utA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=l0QgjfwNFuFrInPAg67q2icejFWSxCvplBbvF8tE6cA=;\n\tb=co1ytkT8ifC7xFlx6nnd2at5txYIbPPgYthsMSbVfx5nRep78Rdca9X/mlkG1xibT+\n\tDyVzRsEKUp6eQahXyCbpMmOZ+9xCvYGM/pl+KzCzdGLx4zMiBBzKhsOxpKQ8sKfhwOLf\n\ts1e+2duiU7o/mV8pyP6L8U8JCor3rKqkbDGARhTGXhbVjmkyvxlU73VaDbTInHjmW3y/\n\t+RvqxBITSL3BlfeRPYKIIkMqzRZ4ljoX3Z47SA5ZGz/cUu25p465dMmPMMO7v4wv8Pid\n\tOzcKCCMZnUamQAMdpKdeqtdOVTifI12jeBRM6/9us5KFNXPjEcFDCrn4wrouEu7xSwxi\n\tSiow==","X-Gm-Message-State":"AOAM533FSnCPp0eYxSgC/1X1/ag55VzPjRgt0t183vF22JKSX+fuWcyP\n\tHC7w6qvBWnRgQ6tfTbeSeWtXOg==","X-Google-Smtp-Source":"ABdhPJyP5eT/RojNXSAisvkzoO8gEAZAQ7Io0ltc4Yl/ECl6bhqQ2yp4kq0gRU7L3idFexPMWo5dRg==","X-Received":"by 2002:a05:651c:318:: with SMTP id\n\ta24mr12778263ljp.381.1621751975300; \n\tSat, 22 May 2021 23:39:35 -0700 (PDT)","Date":"Sun, 23 May 2021 08:39:33 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<YKn4pRVoHlzUpwq8@oden.dyn.berto.se>","References":"<20210523023155.20268-1-laurent.pinchart@ideasonboard.com>\n\t<20210523023155.20268-2-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20210523023155.20268-2-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 1/4] libcamera: thread: Document\n\tdispatchMessages() thread-safety requirements","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":17158,"web_url":"https://patchwork.libcamera.org/comment/17158/","msgid":"<1e01789f-f909-95c0-4c81-6a52a3a55155@ideasonboard.com>","date":"2021-05-24T02:58:43","subject":"Re: [libcamera-devel] [PATCH 1/4] libcamera: thread: Document\n\tdispatchMessages() thread-safety requirements","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"content":"Hi Laurent\n\nThanks for the patch\n\nOn 5/23/21 8:01 AM, Laurent Pinchart wrote:\n> The Thread class is incorrectly documented as thread-safe, as the\n> dispatchMessages() function isn't thread-safe. Fix the documentation by\n> tagging individual functions as thread-safe as appropriate.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n> ---\n>   src/libcamera/thread.cpp | 17 +++++++++++++++--\n>   1 file changed, 15 insertions(+), 2 deletions(-)\n>\n> diff --git a/src/libcamera/thread.cpp b/src/libcamera/thread.cpp\n> index 198670de33a2..285b808332e8 100644\n> --- a/src/libcamera/thread.cpp\n> +++ b/src/libcamera/thread.cpp\n> @@ -229,8 +229,6 @@ ThreadData *ThreadData::current()\n>    * called. The event loop dispatches events (messages, notifiers and timers)\n>    * sent to the objects living in the thread. This behaviour can be modified by\n>    * overriding the run() function.\n> - *\n> - * \\context This class is \\threadsafe.\n>    */\n>   \n>   /**\n> @@ -361,6 +359,8 @@ void Thread::finishThread()\n>    *\n>    * Calling exit() on a thread that reimplements the run() method and doesn't\n>    * call exec() will likely have no effect.\n> + *\n> + * \\context This function is \\threadsafe.\n>    */\n>   void Thread::exit(int code)\n>   {\n> @@ -383,6 +383,8 @@ void Thread::exit(int code)\n>    * utils::duration::max(), the wait never times out. If the thread is not\n>    * running the function returns immediately.\n>    *\n> + * \\context This function is \\threadsafe.\n> + *\n>    * \\return True if the thread has finished, or false if the wait timed out\n>    */\n>   bool Thread::wait(utils::duration duration)\n> @@ -412,6 +414,8 @@ bool Thread::wait(utils::duration duration)\n>    * started. This method guarantees that it returns true after the start()\n>    * method returns, and false after the wait() method returns.\n>    *\n> + * \\context This function is \\threadsafe.\n> + *\n>    * \\return True if the thread is running, false otherwise\n>    */\n>   bool Thread::isRunning()\n> @@ -427,6 +431,7 @@ bool Thread::isRunning()\n>   \n>   /**\n>    * \\brief Retrieve the Thread instance for the current thread\n> + * \\context This function is \\threadsafe.\n>    * \\return The Thread instance for the current thread\n>    */\n>   Thread *Thread::current()\n> @@ -441,6 +446,8 @@ Thread *Thread::current()\n>    * The thread ID corresponds to the Linux thread ID (TID) as returned by the\n>    * gettid system call.\n>    *\n> + * \\context This function is \\threadsafe.\n> + *\n>    * \\return The ID of the current thread\n>    */\n>   pid_t Thread::currentId()\n> @@ -455,6 +462,8 @@ pid_t Thread::currentId()\n>    * This function retrieves the internal event dispatcher for the thread. The\n>    * returned event dispatcher is valid until the thread is destroyed.\n>    *\n> + * \\context This function is \\threadsafe.\n> + *\n>    * \\return Pointer to the event dispatcher\n>    */\n>   EventDispatcher *Thread::eventDispatcher()\n> @@ -544,6 +553,10 @@ void Thread::removeMessages(Object *receiver)\n>    * This function immediately dispatches all the messages previously posted for\n>    * this thread with postMessage() that match the message \\a type. If the \\a type\n>    * is Message::Type::None, all messages are dispatched.\n> + *\n> + * Messages shall only be dispatched from the current thread, typically within\n> + * the thread from the run() function. Calling this function outside of the\n> + * thread results in undefined behaviour.\n>    */\n>   void Thread::dispatchMessages(Message::Type type)\n>   {","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id A2983C3201\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 24 May 2021 02:58:50 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F14706891E;\n\tMon, 24 May 2021 04:58:49 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 16F50602AD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 24 May 2021 04:58:49 +0200 (CEST)","from localhost.localdomain (unknown [103.251.226.203])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0FC79476;\n\tMon, 24 May 2021 04:58:47 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Cy3QqQHD\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1621825128;\n\tbh=NCkjkpcDpU/uXOn8vKbyT8E/8ovyyManD5+0ELvrymI=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=Cy3QqQHDmY2yUq6BDKpynLWhNLxUI4ocf3ZbYo+Ch0ObXHC67rW7W73XdgjEEwcl3\n\tqYpkQrfK0aY4d9ozOZjO8Xon8Ou265cRlEJGSkk3fETNSoh7DxD7W4I1r+btk24QWC\n\tGjC99n1p8e3q4o/U1knniM8ePyJ+rRYIDwaKiI1Q=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210523023155.20268-1-laurent.pinchart@ideasonboard.com>\n\t<20210523023155.20268-2-laurent.pinchart@ideasonboard.com>","From":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<1e01789f-f909-95c0-4c81-6a52a3a55155@ideasonboard.com>","Date":"Mon, 24 May 2021 08:28:43 +0530","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101\n\tThunderbird/68.11.0","MIME-Version":"1.0","In-Reply-To":"<20210523023155.20268-2-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8; format=flowed","Content-Transfer-Encoding":"7bit","Content-Language":"en-US","Subject":"Re: [libcamera-devel] [PATCH 1/4] libcamera: thread: Document\n\tdispatchMessages() thread-safety requirements","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":17169,"web_url":"https://patchwork.libcamera.org/comment/17169/","msgid":"<CAO5uPHPg531R-isfmPjAkSgj5BxfzzPch=Bj17vP2SOo4=hcPA@mail.gmail.com>","date":"2021-05-24T05:34:40","subject":"Re: [libcamera-devel] [PATCH 1/4] libcamera: thread: Document\n\tdispatchMessages() thread-safety requirements","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/people/63/","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"content":"Hi Laurent, thank you for the patch.\n\nOn Mon, May 24, 2021 at 11:58 AM Umang Jain <umang.jain@ideasonboard.com>\nwrote:\n\n> Hi Laurent\n>\n> Thanks for the patch\n>\n> On 5/23/21 8:01 AM, Laurent Pinchart wrote:\n> > The Thread class is incorrectly documented as thread-safe, as the\n> > dispatchMessages() function isn't thread-safe. Fix the documentation by\n> > tagging individual functions as thread-safe as appropriate.\n> >\n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n>\n\nReviewed-by: Hirokazu Honda <hiroh@chromium.org>\n\n\n> > ---\n> >   src/libcamera/thread.cpp | 17 +++++++++++++++--\n> >   1 file changed, 15 insertions(+), 2 deletions(-)\n> >\n> > diff --git a/src/libcamera/thread.cpp b/src/libcamera/thread.cpp\n> > index 198670de33a2..285b808332e8 100644\n> > --- a/src/libcamera/thread.cpp\n> > +++ b/src/libcamera/thread.cpp\n> > @@ -229,8 +229,6 @@ ThreadData *ThreadData::current()\n> >    * called. The event loop dispatches events (messages, notifiers and\n> timers)\n> >    * sent to the objects living in the thread. This behaviour can be\n> modified by\n> >    * overriding the run() function.\n> > - *\n> > - * \\context This class is \\threadsafe.\n> >    */\n> >\n> >   /**\n> > @@ -361,6 +359,8 @@ void Thread::finishThread()\n> >    *\n> >    * Calling exit() on a thread that reimplements the run() method and\n> doesn't\n> >    * call exec() will likely have no effect.\n> > + *\n> > + * \\context This function is \\threadsafe.\n> >    */\n> >   void Thread::exit(int code)\n> >   {\n> > @@ -383,6 +383,8 @@ void Thread::exit(int code)\n> >    * utils::duration::max(), the wait never times out. If the thread is\n> not\n> >    * running the function returns immediately.\n> >    *\n> > + * \\context This function is \\threadsafe.\n> > + *\n> >    * \\return True if the thread has finished, or false if the wait timed\n> out\n> >    */\n> >   bool Thread::wait(utils::duration duration)\n> > @@ -412,6 +414,8 @@ bool Thread::wait(utils::duration duration)\n> >    * started. This method guarantees that it returns true after the\n> start()\n> >    * method returns, and false after the wait() method returns.\n> >    *\n> > + * \\context This function is \\threadsafe.\n> > + *\n> >    * \\return True if the thread is running, false otherwise\n> >    */\n> >   bool Thread::isRunning()\n> > @@ -427,6 +431,7 @@ bool Thread::isRunning()\n> >\n> >   /**\n> >    * \\brief Retrieve the Thread instance for the current thread\n> > + * \\context This function is \\threadsafe.\n> >    * \\return The Thread instance for the current thread\n> >    */\n> >   Thread *Thread::current()\n> > @@ -441,6 +446,8 @@ Thread *Thread::current()\n> >    * The thread ID corresponds to the Linux thread ID (TID) as returned\n> by the\n> >    * gettid system call.\n> >    *\n> > + * \\context This function is \\threadsafe.\n> > + *\n> >    * \\return The ID of the current thread\n> >    */\n> >   pid_t Thread::currentId()\n> > @@ -455,6 +462,8 @@ pid_t Thread::currentId()\n> >    * This function retrieves the internal event dispatcher for the\n> thread. The\n> >    * returned event dispatcher is valid until the thread is destroyed.\n> >    *\n> > + * \\context This function is \\threadsafe.\n> > + *\n> >    * \\return Pointer to the event dispatcher\n> >    */\n> >   EventDispatcher *Thread::eventDispatcher()\n> > @@ -544,6 +553,10 @@ void Thread::removeMessages(Object *receiver)\n> >    * This function immediately dispatches all the messages previously\n> posted for\n> >    * this thread with postMessage() that match the message \\a type. If\n> the \\a type\n> >    * is Message::Type::None, all messages are dispatched.\n> > + *\n> > + * Messages shall only be dispatched from the current thread, typically\n> within\n> > + * the thread from the run() function. Calling this function outside of\n> the\n> > + * thread results in undefined behaviour.\n> >    */\n> >   void Thread::dispatchMessages(Message::Type type)\n> >   {\n>\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id BACEFC3201\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 24 May 2021 05:34:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1942B6891E;\n\tMon, 24 May 2021 07:34:54 +0200 (CEST)","from mail-ej1-x629.google.com (mail-ej1-x629.google.com\n\t[IPv6:2a00:1450:4864:20::629])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0238C602AD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 24 May 2021 07:34:51 +0200 (CEST)","by mail-ej1-x629.google.com with SMTP id s22so39607788ejv.12\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 23 May 2021 22:34:51 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"CHO3qk4b\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=SoT6wpUKaUhuTe646yestX2zHHuVgQtRL1cSDXoeYzE=;\n\tb=CHO3qk4bZ7sRzBihEssFJQghG6FI7vZIK1CkOB18XXy5d4iTmc4MNLR8nbVckTb8TW\n\tHAxXw5jMLNn1s16sXwWzOAM5HXzExxAV+zYbAatiHrAHxvEr0jjuiC63btMZ1k80Z2QS\n\tkGI5nYS/ExmyA6NZT1cTW0DazOBOmuTZ0KhJ0=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=SoT6wpUKaUhuTe646yestX2zHHuVgQtRL1cSDXoeYzE=;\n\tb=elSanIN/6uUi5EN8hYCgp10tXQBsem2o32LPqErbTGBhTbWip/fNTDk8J6HJlTl52X\n\twoI6RPtvXdsFhIfPiIQr7zlNin6qzrVAlEIpt9Yk84rt6+nYTj7O6PI09Eer+CKdr0ZL\n\tW/z+QZ7qlqhmeaYP6UHJoi4Z5eRjmTx9303im5cem6B0EboQVmdrONhoj9iYnO4sPpoM\n\tCgs4Qlsek0A/We9FRvWQoS4Fas0mGxvI5FJZbvxIOEDmNCw57wtg+nmoyJVQ2RY2hOnI\n\tp8I/77kegezh2w38G7PWNzDDwqehgFHkZJAGm53J9xlLKm5/hkNRY0Ic+z8Ys3GBPmIW\n\tO8pA==","X-Gm-Message-State":"AOAM533SrEMn+LgW9W1awgnAF6LkawYBmGCNcxEL7pvP8xCwVG76Kebg\n\tLSrys8MO2fmM56vqQxyNImLSTP9L7rnCVPRh5OjaIw==","X-Google-Smtp-Source":"ABdhPJxF7N2vadjP8e4Cafn+ndNCk+VxGq0vpnMEmE8hzLtyaX3XZeOQ7E78GIDSMV8+oyDlulHUuFp2czXN44kFxqs=","X-Received":"by 2002:a17:906:ecf9:: with SMTP id\n\tqt25mr21681818ejb.55.1621834491649; \n\tSun, 23 May 2021 22:34:51 -0700 (PDT)","MIME-Version":"1.0","References":"<20210523023155.20268-1-laurent.pinchart@ideasonboard.com>\n\t<20210523023155.20268-2-laurent.pinchart@ideasonboard.com>\n\t<1e01789f-f909-95c0-4c81-6a52a3a55155@ideasonboard.com>","In-Reply-To":"<1e01789f-f909-95c0-4c81-6a52a3a55155@ideasonboard.com>","From":"Hirokazu Honda <hiroh@chromium.org>","Date":"Mon, 24 May 2021 14:34:40 +0900","Message-ID":"<CAO5uPHPg531R-isfmPjAkSgj5BxfzzPch=Bj17vP2SOo4=hcPA@mail.gmail.com>","To":"Umang Jain <umang.jain@ideasonboard.com>","Content-Type":"multipart/alternative; boundary=\"000000000000c2742605c30cc446\"","Subject":"Re: [libcamera-devel] [PATCH 1/4] libcamera: thread: Document\n\tdispatchMessages() thread-safety requirements","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":17176,"web_url":"https://patchwork.libcamera.org/comment/17176/","msgid":"<20210524085246.emzsu4oxfre5btnb@uno.localdomain>","date":"2021-05-24T08:52:46","subject":"Re: [libcamera-devel] [PATCH 1/4] libcamera: thread: Document\n\tdispatchMessages() thread-safety requirements","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Laurent\n\nOn Sun, May 23, 2021 at 05:31:52AM +0300, Laurent Pinchart wrote:\n> The Thread class is incorrectly documented as thread-safe, as the\n> dispatchMessages() function isn't thread-safe. Fix the documentation by\n> tagging individual functions as thread-safe as appropriate.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  src/libcamera/thread.cpp | 17 +++++++++++++++--\n>  1 file changed, 15 insertions(+), 2 deletions(-)\n>\n> diff --git a/src/libcamera/thread.cpp b/src/libcamera/thread.cpp\n> index 198670de33a2..285b808332e8 100644\n> --- a/src/libcamera/thread.cpp\n> +++ b/src/libcamera/thread.cpp\n> @@ -229,8 +229,6 @@ ThreadData *ThreadData::current()\n>   * called. The event loop dispatches events (messages, notifiers and timers)\n>   * sent to the objects living in the thread. This behaviour can be modified by\n>   * overriding the run() function.\n> - *\n> - * \\context This class is \\threadsafe.\n>   */\n>\n>  /**\n> @@ -361,6 +359,8 @@ void Thread::finishThread()\n>   *\n>   * Calling exit() on a thread that reimplements the run() method and doesn't\n>   * call exec() will likely have no effect.\n> + *\n> + * \\context This function is \\threadsafe.\n>   */\n>  void Thread::exit(int code)\n>  {\n> @@ -383,6 +383,8 @@ void Thread::exit(int code)\n>   * utils::duration::max(), the wait never times out. If the thread is not\n>   * running the function returns immediately.\n>   *\n> + * \\context This function is \\threadsafe.\n> + *\n\nNit: we don't usually end this statements with '.'\nBut \\context seems a bit flaky as it has contradicting examples\n\nWhatever feels best for you\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nThanks\n   j\n\n\n>   * \\return True if the thread has finished, or false if the wait timed out\n>   */\n>  bool Thread::wait(utils::duration duration)\n> @@ -412,6 +414,8 @@ bool Thread::wait(utils::duration duration)\n>   * started. This method guarantees that it returns true after the start()\n>   * method returns, and false after the wait() method returns.\n>   *\n> + * \\context This function is \\threadsafe.\n> + *\n>   * \\return True if the thread is running, false otherwise\n>   */\n>  bool Thread::isRunning()\n> @@ -427,6 +431,7 @@ bool Thread::isRunning()\n>\n>  /**\n>   * \\brief Retrieve the Thread instance for the current thread\n> + * \\context This function is \\threadsafe.\n>   * \\return The Thread instance for the current thread\n>   */\n>  Thread *Thread::current()\n> @@ -441,6 +446,8 @@ Thread *Thread::current()\n>   * The thread ID corresponds to the Linux thread ID (TID) as returned by the\n>   * gettid system call.\n>   *\n> + * \\context This function is \\threadsafe.\n> + *\n>   * \\return The ID of the current thread\n>   */\n>  pid_t Thread::currentId()\n> @@ -455,6 +462,8 @@ pid_t Thread::currentId()\n>   * This function retrieves the internal event dispatcher for the thread. The\n>   * returned event dispatcher is valid until the thread is destroyed.\n>   *\n> + * \\context This function is \\threadsafe.\n> + *\n>   * \\return Pointer to the event dispatcher\n>   */\n>  EventDispatcher *Thread::eventDispatcher()\n> @@ -544,6 +553,10 @@ void Thread::removeMessages(Object *receiver)\n>   * This function immediately dispatches all the messages previously posted for\n>   * this thread with postMessage() that match the message \\a type. If the \\a type\n>   * is Message::Type::None, all messages are dispatched.\n> + *\n> + * Messages shall only be dispatched from the current thread, typically within\n> + * the thread from the run() function. Calling this function outside of the\n> + * thread results in undefined behaviour.\n>   */\n>  void Thread::dispatchMessages(Message::Type type)\n>  {\n> --\n> Regards,\n>\n> Laurent Pinchart\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id A8A27C3201\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 24 May 2021 08:52:03 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C7B4468919;\n\tMon, 24 May 2021 10:52:02 +0200 (CEST)","from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net\n\t[217.70.183.200])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 19DB1602B1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 24 May 2021 10:52:01 +0200 (CEST)","(Authenticated sender: jacopo@jmondi.org)\n\tby relay7-d.mail.gandi.net (Postfix) with ESMTPSA id A44202000B;\n\tMon, 24 May 2021 08:52:00 +0000 (UTC)"],"Date":"Mon, 24 May 2021 10:52:46 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20210524085246.emzsu4oxfre5btnb@uno.localdomain>","References":"<20210523023155.20268-1-laurent.pinchart@ideasonboard.com>\n\t<20210523023155.20268-2-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210523023155.20268-2-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 1/4] libcamera: thread: Document\n\tdispatchMessages() thread-safety requirements","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":17180,"web_url":"https://patchwork.libcamera.org/comment/17180/","msgid":"<YKtxQN/X1HJuJOEz@pendragon.ideasonboard.com>","date":"2021-05-24T09:26:24","subject":"Re: [libcamera-devel] [PATCH 1/4] libcamera: thread: Document\n\tdispatchMessages() thread-safety requirements","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nOn Mon, May 24, 2021 at 10:52:46AM +0200, Jacopo Mondi wrote:\n> On Sun, May 23, 2021 at 05:31:52AM +0300, Laurent Pinchart wrote:\n> > The Thread class is incorrectly documented as thread-safe, as the\n> > dispatchMessages() function isn't thread-safe. Fix the documentation by\n> > tagging individual functions as thread-safe as appropriate.\n> >\n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >  src/libcamera/thread.cpp | 17 +++++++++++++++--\n> >  1 file changed, 15 insertions(+), 2 deletions(-)\n> >\n> > diff --git a/src/libcamera/thread.cpp b/src/libcamera/thread.cpp\n> > index 198670de33a2..285b808332e8 100644\n> > --- a/src/libcamera/thread.cpp\n> > +++ b/src/libcamera/thread.cpp\n> > @@ -229,8 +229,6 @@ ThreadData *ThreadData::current()\n> >   * called. The event loop dispatches events (messages, notifiers and timers)\n> >   * sent to the objects living in the thread. This behaviour can be modified by\n> >   * overriding the run() function.\n> > - *\n> > - * \\context This class is \\threadsafe.\n> >   */\n> >\n> >  /**\n> > @@ -361,6 +359,8 @@ void Thread::finishThread()\n> >   *\n> >   * Calling exit() on a thread that reimplements the run() method and doesn't\n> >   * call exec() will likely have no effect.\n> > + *\n> > + * \\context This function is \\threadsafe.\n> >   */\n> >  void Thread::exit(int code)\n> >  {\n> > @@ -383,6 +383,8 @@ void Thread::exit(int code)\n> >   * utils::duration::max(), the wait never times out. If the thread is not\n> >   * running the function returns immediately.\n> >   *\n> > + * \\context This function is \\threadsafe.\n> > + *\n> \n> Nit: we don't usually end this statements with '.'\n> But \\context seems a bit flaky as it has contradicting examples\n\nI've had a look, and if I don't specify a period at the end, doxygen\ndoesn't add one, unlike for \\brief. I'd thus prefer keeping it.\n\n> Whatever feels best for you\n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n> \n> >   * \\return True if the thread has finished, or false if the wait timed out\n> >   */\n> >  bool Thread::wait(utils::duration duration)\n> > @@ -412,6 +414,8 @@ bool Thread::wait(utils::duration duration)\n> >   * started. This method guarantees that it returns true after the start()\n> >   * method returns, and false after the wait() method returns.\n> >   *\n> > + * \\context This function is \\threadsafe.\n> > + *\n> >   * \\return True if the thread is running, false otherwise\n> >   */\n> >  bool Thread::isRunning()\n> > @@ -427,6 +431,7 @@ bool Thread::isRunning()\n> >\n> >  /**\n> >   * \\brief Retrieve the Thread instance for the current thread\n> > + * \\context This function is \\threadsafe.\n> >   * \\return The Thread instance for the current thread\n> >   */\n> >  Thread *Thread::current()\n> > @@ -441,6 +446,8 @@ Thread *Thread::current()\n> >   * The thread ID corresponds to the Linux thread ID (TID) as returned by the\n> >   * gettid system call.\n> >   *\n> > + * \\context This function is \\threadsafe.\n> > + *\n> >   * \\return The ID of the current thread\n> >   */\n> >  pid_t Thread::currentId()\n> > @@ -455,6 +462,8 @@ pid_t Thread::currentId()\n> >   * This function retrieves the internal event dispatcher for the thread. The\n> >   * returned event dispatcher is valid until the thread is destroyed.\n> >   *\n> > + * \\context This function is \\threadsafe.\n> > + *\n> >   * \\return Pointer to the event dispatcher\n> >   */\n> >  EventDispatcher *Thread::eventDispatcher()\n> > @@ -544,6 +553,10 @@ void Thread::removeMessages(Object *receiver)\n> >   * This function immediately dispatches all the messages previously posted for\n> >   * this thread with postMessage() that match the message \\a type. If the \\a type\n> >   * is Message::Type::None, all messages are dispatched.\n> > + *\n> > + * Messages shall only be dispatched from the current thread, typically within\n> > + * the thread from the run() function. Calling this function outside of the\n> > + * thread results in undefined behaviour.\n> >   */\n> >  void Thread::dispatchMessages(Message::Type type)\n> >  {","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 15C6DC3201\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 24 May 2021 09:26:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8A2D568919;\n\tMon, 24 May 2021 11:26:30 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8D039602B1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 24 May 2021 11:26:28 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0454A140C;\n\tMon, 24 May 2021 11:26:27 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"uqR7habs\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1621848388;\n\tbh=ZgCs9uyhaPbigrPQylHnhxJCsxmp5WEoC+IMBoEBe50=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=uqR7habs3jehSJ50h1XYWFSQqZFcPLkX0q5xpnXAt6MKXf7g1jmfxGsfqnaIe5tyb\n\tLjr/zIvXCXNmOis/x2/T5ybO7NkIzlac/Jro1nUhaktRGrWTQeg/Byus/Cg/CsC/23\n\tH269PQVqZDnqXP8N3x8h207SfjUj4SqFmkUPEBd4=","Date":"Mon, 24 May 2021 12:26:24 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<YKtxQN/X1HJuJOEz@pendragon.ideasonboard.com>","References":"<20210523023155.20268-1-laurent.pinchart@ideasonboard.com>\n\t<20210523023155.20268-2-laurent.pinchart@ideasonboard.com>\n\t<20210524085246.emzsu4oxfre5btnb@uno.localdomain>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210524085246.emzsu4oxfre5btnb@uno.localdomain>","Subject":"Re: [libcamera-devel] [PATCH 1/4] libcamera: thread: Document\n\tdispatchMessages() thread-safety requirements","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]