[{"id":33316,"web_url":"https://patchwork.libcamera.org/comment/33316/","msgid":"<3gxeyiqy5p2lte5xlpi2xl47x2ywbjje76nw77nmvgtne3ettr@gh4ilm5a2wzi>","date":"2025-02-06T17:34:14","subject":"Re: [RFC PATCH v3 20/21] apps: lc-compliance: Make `EventLoop` a\n\tmember","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Barnabás\n\nOn Thu, Jan 30, 2025 at 11:51:46AM +0000, Barnabás Pőcze wrote:\n> Instead of creating an `EventLoop` in each `run()` invocation\n> and setting a member pointer to the on-stack object, simply\n> make it a member variable.\n>\n> Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>\n\nI wonder if this could be merged with 16/21\n\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nThanks\n  j\n\n> ---\n>  src/apps/lc-compliance/helpers/capture.cpp | 11 ++++-------\n>  src/apps/lc-compliance/helpers/capture.h   |  2 +-\n>  2 files changed, 5 insertions(+), 8 deletions(-)\n>\n> diff --git a/src/apps/lc-compliance/helpers/capture.cpp b/src/apps/lc-compliance/helpers/capture.cpp\n> index 5032470d9..13a5e3f33 100644\n> --- a/src/apps/lc-compliance/helpers/capture.cpp\n> +++ b/src/apps/lc-compliance/helpers/capture.cpp\n> @@ -69,16 +69,13 @@ void Capture::run(unsigned int captureLimit, std::optional<unsigned int> queueLi\n>\n>  \tcaptureCount_ = queueCount_ = 0;\n>\n> -\tEventLoop loop;\n> -\tloop_ = &loop;\n> -\n>  \tstart();\n>  \tprepareRequests();\n>\n>  \tfor (const auto &request : requests_)\n>  \t\tqueueRequest(request.get());\n>\n> -\tEXPECT_EQ(loop_->exec(), 0);\n> +\tEXPECT_EQ(loop_.exec(), 0);\n>\n>  \tstop();\n>\n> @@ -140,7 +137,7 @@ void Capture::requestComplete(Request *request)\n>  {\n>  \tcaptureCount_++;\n>  \tif (captureCount_ >= captureLimit_) {\n> -\t\tloop_->exit(0);\n> +\t\tloop_.exit(0);\n>  \t\treturn;\n>  \t}\n>\n> @@ -170,7 +167,7 @@ void Capture::start()\n>  \tcamera_->requestCompleted.connect(this, [this](libcamera::Request *request) {\n>  \t\t/* Runs in the CameraManager thread. */\n>\n> -\t\tloop_->callLater([this, request] {\n> +\t\tloop_.callLater([this, request] {\n>  \t\t\t/* Run handler in the context of the event loop. */\n>  \t\t\trequestComplete(request);\n>  \t\t}, reinterpret_cast<std::uintptr_t>(this));\n> @@ -190,7 +187,7 @@ void Capture::stop()\n>\n>  \trequests_.clear();\n>\n> -\tloop_->cancelLater(reinterpret_cast<std::uintptr_t>(this));\n> +\tloop_.cancelLater(reinterpret_cast<std::uintptr_t>(this));\n>\n>  \tfor (const auto &cfg : *config_) {\n>  \t\tint ret = allocator_.free(cfg.stream());\n> diff --git a/src/apps/lc-compliance/helpers/capture.h b/src/apps/lc-compliance/helpers/capture.h\n> index dacce1fe2..50dc37c28 100644\n> --- a/src/apps/lc-compliance/helpers/capture.h\n> +++ b/src/apps/lc-compliance/helpers/capture.h\n> @@ -38,7 +38,7 @@ private:\n>  \tstd::unique_ptr<libcamera::CameraConfiguration> config_;\n>  \tstd::vector<std::unique_ptr<libcamera::Request>> requests_;\n>\n> -\tEventLoop *loop_ = nullptr;\n> +\tEventLoop loop_;\n>  \tunsigned int captureLimit_ = 0;\n>  \tstd::optional<unsigned int> queueLimit_;\n>  \tunsigned int captureCount_ = 0;\n> --\n> 2.48.1\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 2AFCEC32EA\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  6 Feb 2025 17:34:19 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DD912685FA;\n\tThu,  6 Feb 2025 18:34:18 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D23376053F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  6 Feb 2025 18:34:17 +0100 (CET)","from ideasonboard.com (mob-5-90-139-204.net.vodafone.it\n\t[5.90.139.204])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0634D1198;\n\tThu,  6 Feb 2025 18:33:03 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"tGN8s23n\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1738863184;\n\tbh=GznI+ZZf1cA/RT0YibmGHrkIlhkN2K+jJ9D3g9FOMgw=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=tGN8s23n0yas5yZRHYqezB7+fzHfHHJDHlrJqyl1KTp7Vay+YmfUXPexJcBHqQv/N\n\tqELBbBj/I1B65wC1W46hZ07Ud4kyz5jf1ZKBCD75ZTlINJm2kiVrmeTHWH81buxew/\n\t3SNOsJGISFktJnI/mxjEBcXAarpgioOfqQ1D3wPY=","Date":"Thu, 6 Feb 2025 18:34:14 +0100","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [RFC PATCH v3 20/21] apps: lc-compliance: Make `EventLoop` a\n\tmember","Message-ID":"<3gxeyiqy5p2lte5xlpi2xl47x2ywbjje76nw77nmvgtne3ettr@gh4ilm5a2wzi>","References":"<20250130115001.1129305-1-pobrn@protonmail.com>\n\t<20250130115001.1129305-21-pobrn@protonmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20250130115001.1129305-21-pobrn@protonmail.com>","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>"}}]