Show a patch.

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

{
    "id": 22660,
    "url": "https://patchwork.libcamera.org/api/patches/22660/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/22660/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/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-2-pobrn@protonmail.com>",
    "date": "2025-01-30T11:50:08",
    "name": "[RFC,v3,01/21] apps: common: event_loop: Take callbacks by rvalue ref",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "ca2fb90fa2522365e0202b29dd453c0aacb12eb2",
    "submitter": {
        "id": 133,
        "url": "https://patchwork.libcamera.org/api/people/133/?format=api",
        "name": "Pőcze Barnabás",
        "email": "pobrn@protonmail.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/22660/mbox/",
    "series": [
        {
            "id": 4978,
            "url": "https://patchwork.libcamera.org/api/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/22660/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/22660/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 22E7EBDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 30 Jan 2025 11:50:16 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4F5DE68563;\n\tThu, 30 Jan 2025 12:50:15 +0100 (CET)",
            "from mail-40134.protonmail.ch (mail-40134.protonmail.ch\n\t[185.70.40.134])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 871876034C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 30 Jan 2025 12:50:13 +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=\"WeJxizlH\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;\n\ts=protonmail3; t=1738237812; x=1738497012;\n\tbh=nx5skBNCz7i+955ZPFMrLg8EFjHcpon5EJqDadeZ0uw=;\n\th=Date:To:From:Cc: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=WeJxizlHbUecy2jTRitY6EEz57fEE/ZP2a1Tg7+8zgdTNvpyxfi7y3A4Qpmed0/dE\n\txdoldLgtvYosC0FBqrB3Ek70eDx4qtTU0VyFV8M1th6O8uPNbbvAmtrSYxrr5tPecK\n\tSexuefZ5uEBmfayuWo3tgd9ihyDTss9joCG0iHr+hdb/y9M3v8y8pny4V249D80LRV\n\tqIC4w9sP4Z6rB1k1KuUb5ij7Ya3sLMztMpc0v/Gl7KEcKhSKrVos6C4/89/8kig27S\n\tME+4NwDCV5OVa2BOefNvAGzuFtd18Xw9VRS2TuYmQ0EhdBXHghbHkKQ5VOPRrdQZlN\n\t63B5qn7SyxzRQ==",
        "Date": "Thu, 30 Jan 2025 11:50:08 +0000",
        "To": "libcamera-devel@lists.libcamera.org",
        "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>",
        "Cc": "Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tPaul Elder <paul.elder@ideasonboard.com>",
        "Subject": "[RFC PATCH v3 01/21] apps: common: event_loop: Take callbacks by\n\trvalue ref",
        "Message-ID": "<20250130115001.1129305-2-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": "20fb6a77ee7f601afe43b05fb225494ea8a04396",
        "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": "Using a const lvalue reference to `std::function<>` is not ideal\nbecause it forces a copy to happen. Use an rvalue reference and\n`std::move()` to avoid that.\n\nSigned-off-by: Barnabás Pőcze <pobrn@protonmail.com>\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n---\n src/apps/common/event_loop.cpp | 16 ++++++++--------\n src/apps/common/event_loop.h   |  8 ++++----\n 2 files changed, 12 insertions(+), 12 deletions(-)",
    "diff": "diff --git a/src/apps/common/event_loop.cpp b/src/apps/common/event_loop.cpp\nindex f7f9afa0c..bc8cf17ab 100644\n--- a/src/apps/common/event_loop.cpp\n+++ b/src/apps/common/event_loop.cpp\n@@ -50,20 +50,20 @@ void EventLoop::exit(int code)\n \tevent_base_loopbreak(base_);\n }\n \n-void EventLoop::callLater(const std::function<void()> &func)\n+void EventLoop::callLater(std::function<void()> &&func)\n {\n \t{\n \t\tstd::unique_lock<std::mutex> locker(lock_);\n-\t\tcalls_.push_back(func);\n+\t\tcalls_.push_back(std::move(func));\n \t}\n \n \tevent_base_once(base_, -1, EV_TIMEOUT, dispatchCallback, this, nullptr);\n }\n \n void EventLoop::addFdEvent(int fd, EventType type,\n-\t\t\t   const std::function<void()> &callback)\n+\t\t\t   std::function<void()> &&callback)\n {\n-\tstd::unique_ptr<Event> event = std::make_unique<Event>(callback);\n+\tstd::unique_ptr<Event> event = std::make_unique<Event>(std::move(callback));\n \tshort events = (type & Read ? EV_READ : 0)\n \t\t     | (type & Write ? EV_WRITE : 0)\n \t\t     | EV_PERSIST;\n@@ -85,9 +85,9 @@ void EventLoop::addFdEvent(int fd, EventType type,\n }\n \n void EventLoop::addTimerEvent(const std::chrono::microseconds period,\n-\t\t\t      const std::function<void()> &callback)\n+\t\t\t      std::function<void()> &&callback)\n {\n-\tstd::unique_ptr<Event> event = std::make_unique<Event>(callback);\n+\tstd::unique_ptr<Event> event = std::make_unique<Event>(std::move(callback));\n \tevent->event_ = event_new(base_, -1, EV_PERSIST, &EventLoop::Event::dispatch,\n \t\t\t\t  event.get());\n \tif (!event->event_) {\n@@ -131,8 +131,8 @@ void EventLoop::dispatchCall()\n \tcall();\n }\n \n-EventLoop::Event::Event(const std::function<void()> &callback)\n-\t: callback_(callback), event_(nullptr)\n+EventLoop::Event::Event(std::function<void()> &&callback)\n+\t: callback_(std::move(callback)), event_(nullptr)\n {\n }\n \ndiff --git a/src/apps/common/event_loop.h b/src/apps/common/event_loop.h\nindex ef129b9aa..d7d012c76 100644\n--- a/src/apps/common/event_loop.h\n+++ b/src/apps/common/event_loop.h\n@@ -33,18 +33,18 @@ public:\n \tint exec();\n \tvoid exit(int code = 0);\n \n-\tvoid callLater(const std::function<void()> &func);\n+\tvoid callLater(std::function<void()> &&func);\n \n \tvoid addFdEvent(int fd, EventType type,\n-\t\t\tconst std::function<void()> &handler);\n+\t\t\tstd::function<void()> &&handler);\n \n \tusing duration = std::chrono::steady_clock::duration;\n \tvoid addTimerEvent(const std::chrono::microseconds period,\n-\t\t\t   const std::function<void()> &handler);\n+\t\t\t   std::function<void()> &&handler);\n \n private:\n \tstruct Event {\n-\t\tEvent(const std::function<void()> &callback);\n+\t\tEvent(std::function<void()> &&callback);\n \t\t~Event();\n \n \t\tstatic void dispatch(int fd, short events, void *arg);\n",
    "prefixes": [
        "RFC",
        "v3",
        "01/21"
    ]
}