Show a patch.

GET /api/1.1/patches/22662/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 22662,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/22662/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/22662/",
    "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": "<20250130115001.1129305-5-pobrn@protonmail.com>",
    "date": "2025-01-30T11:50:23",
    "name": "[RFC,v3,04/21] apps: common: event_loop: Use single event source for deferred calls",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "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/22662/mbox/",
    "series": [
        {
            "id": 4978,
            "url": "https://patchwork.libcamera.org/api/1.1/series/4978/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4978",
            "date": "2025-01-30T11:50:08",
            "name": "apps: lc-compliance: Multi-stream tests",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/4978/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/22662/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/22662/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 41E43BDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 30 Jan 2025 11:50:29 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0CBE468567;\n\tThu, 30 Jan 2025 12:50:29 +0100 (CET)",
            "from mail-4316.protonmail.ch (mail-4316.protonmail.ch\n\t[185.70.43.16])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 61AFD68567\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 30 Jan 2025 12:50:27 +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=\"xpmgCBr7\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;\n\ts=protonmail3; t=1738237826; x=1738497026;\n\tbh=zTJlVF9VecSivZdM7mHggxshRZizFlrVHInQxMvM9Xw=;\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=xpmgCBr7n5o/28Up94qw5sPHZXS0lCHPh4WpU2JWq/D4v+LVEw8sAs5EyknA3fvLW\n\tMIgNkp+3O4+6BWUKl/+aNZ2nPRJi6pOE2Jdh4iqcf0Ecz972zNQ2pu0q78aIWLrVrL\n\tzQlOnasuCyBBFY3zAEXJdS8F7CHROGh1EjqqV+Kfd/aiYL8iov593GMNpydt5rdVuO\n\t2STanDNmgKw8MGqijhfY8ucKwvWnOfe0e2XYmxL56wDGS0RuBPNEs6sS1tQAiqWpb1\n\tzgJM61wX5xmNoNx/4hYViy2fGM6zTpGDXuFGOwm1b23raoD5OPX8Ff/YWoa3WqI6gh\n\tFGPlQKPeFltWw==",
        "Date": "Thu, 30 Jan 2025 11:50:23 +0000",
        "To": "libcamera-devel@lists.libcamera.org",
        "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>",
        "Subject": "[RFC PATCH v3 04/21] apps: common: event_loop: Use single event\n\tsource for deferred calls",
        "Message-ID": "<20250130115001.1129305-5-pobrn@protonmail.com>",
        "In-Reply-To": "<20250130115001.1129305-1-pobrn@protonmail.com>",
        "References": "<20250130115001.1129305-1-pobrn@protonmail.com>",
        "Feedback-ID": "20568564:user:proton",
        "X-Pm-Message-ID": "ae2c0c9f34f3fac4d10449178f413ab0823d239e",
        "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",
        "v3",
        "04/21"
    ]
}