Patch Detail
Show a patch.
GET /api/1.1/patches/22565/?format=api
{ "id": 22565, "url": "https://patchwork.libcamera.org/api/1.1/patches/22565/?format=api", "web_url": "https://patchwork.libcamera.org/patch/22565/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20250114182143.1773762-5-pobrn@protonmail.com>", "date": "2025-01-14T18:22:05", "name": "[RFC,v2,04/16] apps: common: event_loop: Use single event source for deferred calls", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "69bbac1faea9a937537a69409922ff129169b02d", "submitter": { "id": 133, "url": "https://patchwork.libcamera.org/api/1.1/people/133/?format=api", "name": "Pőcze Barnabás", "email": "pobrn@protonmail.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/22565/mbox/", "series": [ { "id": 4951, "url": "https://patchwork.libcamera.org/api/1.1/series/4951/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4951", "date": "2025-01-14T18:21:46", "name": "apps: lc-compliance: Multi-stream tests", "version": 2, "mbox": "https://patchwork.libcamera.org/series/4951/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/22565/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/22565/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 9B288C3301\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 14 Jan 2025 18:22:13 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 531F46854C;\n\tTue, 14 Jan 2025 19:22:13 +0100 (CET)", "from mail-10630.protonmail.ch (mail-10630.protonmail.ch\n\t[79.135.106.30])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5F0D7607D6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 14 Jan 2025 19:22:11 +0100 (CET)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=protonmail.com header.i=@protonmail.com\n\theader.b=\"YtVt2fNB\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;\n\ts=protonmail3; t=1736878930; x=1737138130;\n\tbh=NSMHeTnI4K52UGXlbwGm11XKs7nSUJCQPrWb2OYN1lI=;\n\th=Date:To:From:Subject:Message-ID:In-Reply-To:References:\n\tFeedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:\n\tMessage-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post;\n\tb=YtVt2fNBftK0P05kLFVaDLHTXTEZ5Zvam8Hd/4q33PhaTZxY4h24kKNd1NZgaP1lU\n\ti7Vsj+Hozko+ibxRHukPpkUyoDWqlI1xxyxF/0wRM29Tm69ce88dLzdoTzt4XpdYNn\n\tBl0kj88q4FvOhe/lwdALgcsARQjiB/IMhCi0jPFD8t8uo+WXcWK2zuMxfleobxx+on\n\tO95DhyGKORxWVGZtAnKvDFQokMl7qxxkRO0qpUmXuXSfr9ZXUC0hhEsOvxQ3NaIGRH\n\titSZvtuTtV+Qkk2MIx3y4bvozdY5XeCYvfz9CybjC2l6f/zfLsmsODaBLhW+v7RcmW\n\tQ8MmJE+lgrk0g==", "Date": "Tue, 14 Jan 2025 18:22:05 +0000", "To": "libcamera-devel@lists.libcamera.org", "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>", "Subject": "[RFC PATCH v2 04/16] apps: common: event_loop: Use single event\n\tsource for deferred calls", "Message-ID": "<20250114182143.1773762-5-pobrn@protonmail.com>", "In-Reply-To": "<20250114182143.1773762-1-pobrn@protonmail.com>", "References": "<20250114182143.1773762-1-pobrn@protonmail.com>", "Feedback-ID": "20568564:user:proton", "X-Pm-Message-ID": "2eccf59ec2fea8f02dd4317feac02a6d2686145c", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=utf-8", "Content-Transfer-Encoding": "quoted-printable", "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>" }, "content": "Instead of calling `event_base_once()` every time a deferred call\nis added to the loop, create an event source at construction, and\nsimply trigger that when a new deferred call is scheduled.\n\nSigned-off-by: Barnabás Pőcze <pobrn@protonmail.com>\n---\n src/apps/common/event_loop.cpp | 48 +++++++++++++++++-----------------\n src/apps/common/event_loop.h | 5 +---\n 2 files changed, 25 insertions(+), 28 deletions(-)", "diff": "diff --git a/src/apps/common/event_loop.cpp b/src/apps/common/event_loop.cpp\nindex bc8cf17ab..b6230f4ba 100644\n--- a/src/apps/common/event_loop.cpp\n+++ b/src/apps/common/event_loop.cpp\n@@ -21,12 +21,35 @@ EventLoop::EventLoop()\n \tevthread_use_pthreads();\n \tbase_ = event_base_new();\n \tinstance_ = this;\n+\n+\tcallsTrigger_ = event_new(base_, -1, EV_PERSIST, [](evutil_socket_t, short, void *closure) {\n+\t\tauto *self = static_cast<EventLoop *>(closure);\n+\n+\t\tfor (;;) {\n+\t\t\tstd::function<void()> call;\n+\n+\t\t\t{\n+\t\t\t\tstd::lock_guard locker(self->lock_);\n+\t\t\t\tif (self->calls_.empty())\n+\t\t\t\t\tbreak;\n+\n+\t\t\t\tcall = std::move(self->calls_.front());\n+\t\t\t\tself->calls_.pop_front();\n+\t\t\t}\n+\n+\t\t\tcall();\n+\t\t}\n+\t}, this);\n+\tassert(callsTrigger_);\n+\tevent_add(callsTrigger_, nullptr);\n }\n \n EventLoop::~EventLoop()\n {\n \tinstance_ = nullptr;\n \n+\tevent_free(callsTrigger_);\n+\n \tevents_.clear();\n \tevent_base_free(base_);\n \tlibevent_global_shutdown();\n@@ -57,7 +80,7 @@ void EventLoop::callLater(std::function<void()> &&func)\n \t\tcalls_.push_back(std::move(func));\n \t}\n \n-\tevent_base_once(base_, -1, EV_TIMEOUT, dispatchCallback, this, nullptr);\n+\tevent_active(callsTrigger_, 0, 0);\n }\n \n void EventLoop::addFdEvent(int fd, EventType type,\n@@ -108,29 +131,6 @@ void EventLoop::addTimerEvent(const std::chrono::microseconds period,\n \tevents_.push_back(std::move(event));\n }\n \n-void EventLoop::dispatchCallback([[maybe_unused]] evutil_socket_t fd,\n-\t\t\t\t [[maybe_unused]] short flags, void *param)\n-{\n-\tEventLoop *loop = static_cast<EventLoop *>(param);\n-\tloop->dispatchCall();\n-}\n-\n-void EventLoop::dispatchCall()\n-{\n-\tstd::function<void()> call;\n-\n-\t{\n-\t\tstd::unique_lock<std::mutex> locker(lock_);\n-\t\tif (calls_.empty())\n-\t\t\treturn;\n-\n-\t\tcall = calls_.front();\n-\t\tcalls_.pop_front();\n-\t}\n-\n-\tcall();\n-}\n-\n EventLoop::Event::Event(std::function<void()> &&callback)\n \t: callback_(std::move(callback)), event_(nullptr)\n {\ndiff --git a/src/apps/common/event_loop.h b/src/apps/common/event_loop.h\nindex 760075885..aac5ed3cc 100644\n--- a/src/apps/common/event_loop.h\n+++ b/src/apps/common/event_loop.h\n@@ -65,11 +65,8 @@ private:\n \tint exitCode_;\n \n \tstd::deque<std::function<void()>> calls_;\n+\t::event *callsTrigger_ = nullptr;\n \n \tstd::list<std::unique_ptr<Event>> events_;\n \tstd::mutex lock_;\n-\n-\tstatic void dispatchCallback(evutil_socket_t fd, short flags,\n-\t\t\t\t void *param);\n-\tvoid dispatchCall();\n };\n", "prefixes": [ "RFC", "v2", "04/16" ] }