From patchwork Wed Jun 15 16:26:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 16225 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 50E85BD161 for ; Wed, 15 Jun 2022 16:26:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 75D036563B; Wed, 15 Jun 2022 18:26:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655310412; bh=Zz3mgoEdxlZ0YLtfx20Y4BEyNKgyBga+xVlO69YzjpM=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=l5oYvxaqKcF0CxmIDXEWpcNj4AAHrUKdUFkjG5AKV3kiOkISGUBZayaUfUOuMbeyL dcPg/uk6ukdA3DJ3KW/EuDI2fxRvNsYeHE3rIR4Gml/rMd39+pL9dtFtERPn7tFEEf UlqFe8MFBrVfMwnyjQxRNBnycTunEsFyvxHArDIkBbFg2jTcEyO2Ydi1EGmh+Oa05Q txKbbM+u3FNo/HHs8uurgwTcPhmwB9lb6oGn9pxd1PEKi48TN/EX2qQGlhy6E5KYZX gZIYk2mtASms2io+Ums9OqPjJshLElUdlUoVV7osXSKpuNL4gMwluXGvKXq2nt5TcQ UkGVkjFmqg1Mw== Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4CD1165631 for ; Wed, 15 Jun 2022 18:26:51 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=thaumatec-com.20210112.gappssmtp.com header.i=@thaumatec-com.20210112.gappssmtp.com header.b="TIWBLOD2"; dkim-atps=neutral Received: by mail-wr1-x433.google.com with SMTP id m24so16055843wrb.10 for ; Wed, 15 Jun 2022 09:26:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aqQCb5uzLsNRQWZ/xnGq1V+ALWcNJVzZAg6ePoizt50=; b=TIWBLOD2bbIEEeSZQ9F4tnZU4rNGs/Pw2E9xFLJZ0qgRQww7wDKcdO4IDc6sx+AXCG nSfYAnXt2usclCSCKK0FXZkV+Y8Tlg1WG5IQfixnEZqxGEvaoWdu5ciW34n5VQhgu7Xb 17hSS7fkQ9OKSEkDtoX9IlM6RPYB9ckuh7gvAzU6yN7fdW5sopd5ncBZ6kXbmhPK6sR1 sMmzPYd7A8+HkwuzI30TSLp+hTjqpKpso73wThkCL+igYPaizg+97wyOx/O0r1BY4jqy Fx5ie97UkgS2lPFh8HP3jTFXfrxoZH9icpizQgjqtFR9cmIqBfucvHd9ev3LXctJr1tx 375w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aqQCb5uzLsNRQWZ/xnGq1V+ALWcNJVzZAg6ePoizt50=; b=K5zzOxIY2SWOG22NOR+Q6MOkwiva0Dy/dwsaupHVlVbgbGH+WCfozBnKcQ86ZbE1FV iTzEy+wjfCOjuDLCtXHWDZeCD8/VXJhkMB65qvLJudR0htlAL27bmAQxhl2C19p5Gja8 IAWOyvElU8Pfc9UGWeSp51X5BGFMTnw9YwCzbTIT6crGYCLT+COnZpz99et4OQfJUmmp 1THvzOJIZhMy5eIjizTAt5DafVXGWWiFOPxOSVP+zct5+szU6nfEdYDNAvel1t7f8Vd1 6qJEoFhUbEl38uxv3qNstVIx8DEO6cCr9qVbZ9QeBJZLGKiT4U2cu0BWLeH4ovzb6tBZ 49ow== X-Gm-Message-State: AJIora/AtrHmuy9B07ewq963hAIGe5jAUxf5zX9Firujef3+QZgZOqEU qpP8c7Jl1y5iLjH9QI33/gRY189uLRJC+49O X-Google-Smtp-Source: AGRyM1uP3yxbZFWBGV9EuwE5/5ownbikkUkzlwVApRepKORA/gd2z/Lv28gU6cIPYSUxJk/8g5fnrg== X-Received: by 2002:adf:dc81:0:b0:212:3a72:2f07 with SMTP id r1-20020adfdc81000000b002123a722f07mr603573wrj.714.1655310410943; Wed, 15 Jun 2022 09:26:50 -0700 (PDT) Received: from localhost.localdomain (ip092042140082.rev.nessus.at. [92.42.140.82]) by smtp.gmail.com with ESMTPSA id r17-20020a05600c35d100b0039c8d181ac6sm3135772wmq.26.2022.06.15.09.26.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 09:26:50 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 15 Jun 2022 18:26:01 +0200 Message-Id: <20220615162601.48619-4-dse@thaumatec.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220615162601.48619-1-dse@thaumatec.com> References: <20220615162601.48619-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/3] Documentation: Update the "Start an event loop" section X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Daniel Semkowicz via libcamera-devel From: Daniel Semkowicz Reply-To: Daniel Semkowicz Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Event loop was moved to be a part of CameraManager, so it is no longer a user responsibility to control the event dispatching. --- .../guides/application-developer.rst | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Documentation/guides/application-developer.rst b/Documentation/guides/application-developer.rst index 00bafb10..97c032a5 100644 --- a/Documentation/guides/application-developer.rst +++ b/Documentation/guides/application-developer.rst @@ -27,10 +27,12 @@ defined names and types without the need of prefixing them. #include #include #include + #include #include using namespace libcamera; + using namespace std::chrono_literals; int main() { @@ -506,7 +508,7 @@ and queue all the previously created requests. for (std::unique_ptr &request : requests) camera->queueRequest(request.get()); -Start an event loop +Event loop ~~~~~~~~~~~~~~~~~~~ The libcamera library needs an event loop to monitor and dispatch events @@ -524,17 +526,17 @@ a notifier it is monitoring, it emits the notifier's notifiers' signals and emit application visible events, such as the ``Camera::bufferReady`` and ``Camera::requestCompleted`` signals. -The code below retrieves a reference to the system-wide event dispatcher and for -the a fixed duration of 3 seconds, processes all the events detected in the -system. +Event loop is handled internally by ``CameraManager`` instance in a separate +thread. ``CameraManager::start()`` creates a new thread and starts the event +loop processing. + +As the ``CameraManager`` was already started in our example, we need to prevent +the immediate termination of the application. The code below pauses the main +thread for 3 seconds, so that the event loop thread can process the requests. .. code:: cpp - EventDispatcher *dispatcher = cm->eventDispatcher(); - Timer timer; - timer.start(3000); - while (timer.isRunning()) - dispatcher->processEvents(); + std::this_thread::sleep_for(3000ms); Clean up and stop the application ---------------------------------