{"id":16268,"url":"https://patchwork.libcamera.org/api/1.1/patches/16268/?format=json","web_url":"https://patchwork.libcamera.org/patch/16268/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220617143549.35442-4-dse@thaumatec.com>","date":"2022-06-17T14:35:49","name":"[libcamera-devel,v2,3/3] Documentation: Update the \"Start an event loop\" section","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"3d3db76877758bbc256b3d5f46f77394ab61cdb9","submitter":{"id":126,"url":"https://patchwork.libcamera.org/api/1.1/people/126/?format=json","name":"Daniel Semkowicz","email":"dse@thaumatec.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/16268/mbox/","series":[{"id":3189,"url":"https://patchwork.libcamera.org/api/1.1/series/3189/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3189","date":"2022-06-17T14:35:46","name":"Documentation: Update code examples in Application Writer's Guide","version":2,"mbox":"https://patchwork.libcamera.org/series/3189/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16268/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16268/checks/","tags":{},"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 EAB26C3275\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 17 Jun 2022 14:36:05 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5660B65632;\n\tFri, 17 Jun 2022 16:36:05 +0200 (CEST)","from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com\n\t[IPv6:2a00:1450:4864:20::62e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5B97D65634\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 17 Jun 2022 16:36:04 +0200 (CEST)","by mail-ej1-x62e.google.com with SMTP id hj18so8551716ejb.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 17 Jun 2022 07:36:04 -0700 (PDT)","from localhost.localdomain (ip092042140082.rev.nessus.at.\n\t[92.42.140.82]) by smtp.gmail.com with ESMTPSA id\n\tu20-20020aa7d554000000b0042a2d9af0f8sm3746189edr.79.2022.06.17.07.36.02\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 17 Jun 2022 07:36:03 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1655476565;\n\tbh=hhnoCMzCfRivBh9MgDRXZ3EySgVnoGHUFnZUEy9Y1V8=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=Z0OFWPcfgRynrxTaXrruv4RE/wYav66+HAdPDb05/kGWSRVEYVYfgcBVYvIGLs1db\n\tsMS8c+VfOi/QvY/JmJuftgtkRNIrrgSdkrAHrHlUUCKk2rrjLZNis2LP1fpGj2S29t\n\tEfGoYSnYnO52klFH+gzttP/2yX6Q9N1JriE2Jx8e7wsdDKllbnJrvG/7WF1XrwObOv\n\tXPqhfJNbj0lypROx+aXUX0TJoJg5d1XhUyyr88FtYsYtLn/SZs9ldTSeIBJzT0f8Yk\n\tjO3hbg3SQB2Tv0nMp/CYtWyN9y7qLI2huI+q+uqLhEz0chFBjB7BE7VCzmQ2Vty2Kl\n\tYoVjaM0BjuM2g==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=thaumatec-com.20210112.gappssmtp.com; s=20210112;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=ES6xm68K6Natf3Fld5kgrC9puFGuwBiA/I1sDxCCj00=;\n\tb=iDQg2qMYN5cjkqQZp1jJBDuUY7cc144998os75uMoaJ3S1+fwHErUYN8aJ+vCkoK7r\n\tSr3qIfLBZYUhr19eewMwp4EZ/uNvbby1A4vrYrGm32v2YB5AuetZdU+zrHtvJQRWNMLE\n\tB9063sjyPDRTnooTvCWeFvKDgxIOCO/F4zSF+MD72mXSftt8zu5mlS6BUpF9PYVJ/V8+\n\tEL0jwWkLvfSdiSAqbtMGGjqIKqwnChWh4AwNx06Mskq8v8jN+SBN56J1NTwX0RjlHAfc\n\tWlXdCcusNuJDsUYP3QOCdJ8hURMT2aClfg26eAj5uedbwv1z54yE3JAA3jIbulJA08PM\n\tpDFw=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected)\n\theader.d=thaumatec-com.20210112.gappssmtp.com\n\theader.i=@thaumatec-com.20210112.gappssmtp.com header.b=\"iDQg2qMY\"; \n\tdkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=ES6xm68K6Natf3Fld5kgrC9puFGuwBiA/I1sDxCCj00=;\n\tb=UVsj2d0lwiLw87kaapuzS2sx8pbV9GW3zfMCTs9AxH3HEaurYMSNyKem+HszDZjv5Y\n\tzabof/bxIeb9xPrcJXamPxRUJsPOrbNTRYMXDbrZCkALfgCL3vnfX74olnc/Br4Zc4Vy\n\tVrdvi79Bc1Ct+LBnR9HgMnZcKVqAEkRcWJ+fE//M0Zs7ahMu2wXSrXG/1llkHTlKkHId\n\tkP0ujVcXIwnvGtqSx0gKLfTmm9HyyEF1Rkz1asHz5mlBQKygz/xE3MV2un6Ca1paos/+\n\tiwxYkjigr7UMZ+2mZUeJw+DuviM0r3CZzO2Dy7soi2chTFvl1zXvm46dY/KB1zH2o9Nw\n\tIx9g==","X-Gm-Message-State":"AJIora//LQefYx3ZjkQG/ujgQ9DXwP0Q5IJDchyvFfP9qr0dd8iiAvC4\n\tfaMNxTw1Nfi79Qqi73G8V1iK4bd5HvSbIg==","X-Google-Smtp-Source":"AGRyM1slK5lxJd4t+gZSLGP5/CCKoxWxDu5XKoQsmtdn16a4VLAH7uVyVtEjhn5LS41209UlwBR8uw==","X-Received":"by 2002:a17:906:4f:b0:712:af2:29d9 with SMTP id\n\t15-20020a170906004f00b007120af229d9mr9676537ejg.751.1655476563865; \n\tFri, 17 Jun 2022 07:36:03 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 17 Jun 2022 16:35:49 +0200","Message-Id":"<20220617143549.35442-4-dse@thaumatec.com>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20220617143549.35442-1-dse@thaumatec.com>","References":"<20220617143549.35442-1-dse@thaumatec.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 3/3] Documentation: Update the \"Start\n\tan event loop\" section","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>","From":"Daniel Semkowicz via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Daniel Semkowicz <dse@thaumatec.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Event loop was moved to be a part of CameraManager, so it is no longer\na user responsibility to control the event dispatching.\n\nSigned-off-by: Daniel Semkowicz <dse@thaumatec.com>\n---\n .../guides/application-developer.rst          | 38 ++++++++-----------\n 1 file changed, 16 insertions(+), 22 deletions(-)","diff":"diff --git a/Documentation/guides/application-developer.rst b/Documentation/guides/application-developer.rst\nindex a5f363cf..f4551f58 100644\n--- a/Documentation/guides/application-developer.rst\n+++ b/Documentation/guides/application-developer.rst\n@@ -27,10 +27,12 @@ defined names and types without the need of prefixing them.\n    #include <iomanip>\n    #include <iostream>\n    #include <memory>\n+   #include <thread>\n \n    #include <libcamera/libcamera.h>\n \n    using namespace libcamera;\n+   using namespace std::chrono_literals;\n \n    int main()\n    {\n@@ -506,35 +508,27 @@ and queue all the previously created requests.\n    for (std::unique_ptr<Request> &request : requests)\n        camera->queueRequest(request.get());\n \n-Start an event loop\n+Event processing\n ~~~~~~~~~~~~~~~~~~~\n \n-The libcamera library needs an event loop to monitor and dispatch events\n-generated by the video devices part of the capture pipeline. libcamera provides\n-its own ``EventDispatcher`` class (inspired by the `Qt event system`_) to\n-process and deliver events generated by ``EventNotifiers``.\n+libcamera creates an internal execution thread at `CameraManager::start()`_\n+time to decouple its own event processing from the application's main thread.\n+Applications are thus free to manage their own execution opportunely, and only\n+need to respond to events generated by libcamera emitted through signals.\n \n-.. _Qt event system: https://doc.qt.io/qt-5/eventsandfilters.html\n+.. _CameraManager::start(): https://libcamera.org/api-html/classlibcamera_1_1CameraManager.html#a49e322880a2a26013bb0076788b298c5\n \n-The libcamera library implements this by creating instances of the\n-``EventNotifier`` class, which models a file descriptor event source registered\n-to an ``EventDispatcher``. Whenever the ``EventDispatcher`` detects an event on\n-a notifier it is monitoring, it emits the notifier's\n-``EventNotifier::activated`` signal. The libcamera components connect to the\n-notifiers' signals and emit application visible events, such as the\n-``Camera::bufferReady`` and ``Camera::requestCompleted`` signals.\n-\n-The code below retrieves a reference to the system-wide event dispatcher and for\n-the a fixed duration of 3 seconds, processes all the events detected in the\n-system.\n+Real-world applications will likely either integrate with the event loop of the\n+framework they use, or create their own event loop to respond to user events.\n+For the simple application presented in this example, it is enough to prevent\n+immediate termination by pausing for 3 seconds. During that time, the libcamera\n+thread will generate request completion events that the application will handle\n+in the ``requestComplete()`` slot connected to the ``Camera::requestCompleted``\n+signal.\n \n .. code:: cpp\n \n-   EventDispatcher *dispatcher = cm->eventDispatcher();\n-   Timer timer;\n-   timer.start(3000);\n-   while (timer.isRunning())\n-       dispatcher->processEvents();\n+   std::this_thread::sleep_for(3000ms);\n \n Clean up and stop the application\n ---------------------------------\n","prefixes":["libcamera-devel","v2","3/3"]}