[{"id":33133,"web_url":"https://patchwork.libcamera.org/comment/33133/","msgid":"<t5lwcvlup5gbmxtcnb2y7lsctqo26cn6tngypvtctyd2tf5vzy@bowf7kp6g37l>","date":"2025-01-22T09:05:37","subject":"Re: [RFC PATCH v2 03/16] apps: common: event_loop: Use `std::deque`\n\tinstead of `std::list`","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 Tue, Jan 14, 2025 at 06:22:01PM +0000, Barnabás Pőcze wrote:\n> Deque has fast pop_front and push_back operations while making\n> fewer allocations for the same number of elements as an `std::list`.\n> So use an `std::deque` for storing the deferred calls of the loop.\n>\n> Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>\n\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nThanks\n  j\n\n> ---\n>  src/apps/common/event_loop.h | 4 +++-\n>  1 file changed, 3 insertions(+), 1 deletion(-)\n>\n> diff --git a/src/apps/common/event_loop.h b/src/apps/common/event_loop.h\n> index 4e8dd0a46..760075885 100644\n> --- a/src/apps/common/event_loop.h\n> +++ b/src/apps/common/event_loop.h\n> @@ -8,6 +8,7 @@\n>  #pragma once\n>\n>  #include <chrono>\n> +#include <deque>\n>  #include <functional>\n>  #include <list>\n>  #include <memory>\n> @@ -63,7 +64,8 @@ private:\n>  \tstruct event_base *base_;\n>  \tint exitCode_;\n>\n> -\tstd::list<std::function<void()>> calls_;\n> +\tstd::deque<std::function<void()>> calls_;\n> +\n>  \tstd::list<std::unique_ptr<Event>> events_;\n>  \tstd::mutex lock_;\n>\n> --\n> 2.48.0\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 8E19DBD16B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 22 Jan 2025 09:05:43 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6F97C68559;\n\tWed, 22 Jan 2025 10:05:42 +0100 (CET)","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 EAD4468551\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 22 Jan 2025 10:05:40 +0100 (CET)","from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0EE0C520;\n\tWed, 22 Jan 2025 10:04:38 +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=\"nXbbEzE6\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1737536678;\n\tbh=07uW+0JdMzzXK6EuAUiNTCy2ZeqlIZxZWgUkT7A6rPE=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=nXbbEzE6mEl3ivw1g2IdJ8Ff5810FHw4p9/Pg2a2x9/2dr8U3M9e2oiASixb29nwX\n\tqwYtAN/hwF+/65phAKsXb5+8i2l8euPTm3W4yXHdiqfjMSRdfM9AqGpDV8I6p63W8P\n\tsSviMU0uYgYpXVSHlo4BX0WMPijegyTnHBcZUDic=","Date":"Wed, 22 Jan 2025 10:05:37 +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 v2 03/16] apps: common: event_loop: Use `std::deque`\n\tinstead of `std::list`","Message-ID":"<t5lwcvlup5gbmxtcnb2y7lsctqo26cn6tngypvtctyd2tf5vzy@bowf7kp6g37l>","References":"<20250114182143.1773762-1-pobrn@protonmail.com>\n\t<20250114182143.1773762-4-pobrn@protonmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20250114182143.1773762-4-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>"}}]