Show a patch.

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

{
    "id": 15661,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/15661/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/15661/",
    "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": "<20220408160015.33612-1-ecurtin@redhat.com>",
    "date": "2022-04-08T16:00:14",
    "name": "[libcamera-devel,v7,1/2] cam: event_loop: Add timer events to event loop",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "55187179c800df8834966e2c57deba402cfae887",
    "submitter": {
        "id": 101,
        "url": "https://patchwork.libcamera.org/api/1.1/people/101/?format=api",
        "name": "Eric Curtin",
        "email": "ecurtin@redhat.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/15661/mbox/",
    "series": [
        {
            "id": 3047,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3047/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3047",
            "date": "2022-04-08T16:00:14",
            "name": "[libcamera-devel,v7,1/2] cam: event_loop: Add timer events to event loop",
            "version": 7,
            "mbox": "https://patchwork.libcamera.org/series/3047/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/15661/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/15661/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 A12FDC3256\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  8 Apr 2022 16:00:25 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AF08265642;\n\tFri,  8 Apr 2022 18:00:24 +0200 (CEST)",
            "from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D5E17604BA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  8 Apr 2022 18:00:22 +0200 (CEST)",
            "from mail-wm1-f72.google.com (mail-wm1-f72.google.com\n\t[209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n\tus-mta-657-BvvyTz1PMZmI3IArVY0SBw-1; Fri, 08 Apr 2022 12:00:20 -0400",
            "by mail-wm1-f72.google.com with SMTP id\n\tl4-20020a05600c1d0400b0038eaa928a67so550131wms.7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 08 Apr 2022 09:00:19 -0700 (PDT)",
            "from p1.Home ([2001:8a0:6724:4500:a69c:e66f:828e:b340])\n\tby smtp.gmail.com with ESMTPSA id\n\ta12-20020a5d53cc000000b00205a0ee9c74sm18913521wrw.89.2022.04.08.09.00.17\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 08 Apr 2022 09:00:17 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1649433624;\n\tbh=39TTu31F6IWn1IhidMb9LjoGbN7uxwMkGvIwOoAYiSg=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=Enn829P6Gk0ykCaEhOboTVixhJNp6rAqJ2vCaJqT+SvwIQyss45roxZSGfZ1hTkyI\n\tMO2knKtIKr9mf/W2Djk47C5HZUeLbKkATNRhVnCLdNhCu9Fm+LpCQb836sIR0K0VV4\n\toG3WcrPl8FpXjhh0lNiuvtURo3kwoh01OFfM/DB/TcKmm9WWHpGLYpWynjUtv+TVtE\n\trBptFYuk54djYv5BWmbxzZqirfUsuvw/rBVt4ViJxdiTYg4zi8kKvCBJT9CGaEJEcK\n\tLLla3Kdc96hR+GEvqrIjGNxs0yHtIJ6NVgtvd/NUY7eweV7IGqqoiI38j9yE19+1FR\n\tPtwh9SOHdeARQ==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1649433621;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding;\n\tbh=uUzjs17hCGVsCj1b3oArrT45VOxKw8/vUjWEopdaK+0=;\n\tb=Pon2DWUNClzkqk/MCktVzh4NOFnaY90eM+lQ8hxzfqwhgphgFtxG6izW/jKQ/7UJOhg45v\n\tBofANjug75l5GapvsUtCsHHZSOQwlb8EQAAUgM1xwp0cwVX4xfVpCbRvcEQO/xtbcerhV4\n\tYCCU/NrLNccQD1cfDzvuE3M4xiJud9Y="
        ],
        "Authentication-Results": [
            "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=redhat.com\n\theader.i=@redhat.com header.b=\"Pon2DWUN\"; \n\tdkim-atps=neutral",
            "relay.mimecast.com;\n\tauth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ecurtin@redhat.com"
        ],
        "X-MC-Unique": "BvvyTz1PMZmI3IArVY0SBw-1",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=uUzjs17hCGVsCj1b3oArrT45VOxKw8/vUjWEopdaK+0=;\n\tb=Ek7mT4Mwz2e8GfHdlb9/VbXdwWPL4QWvWHKTIZm7v/BOwDMA/U8hv8b3DLSMsSGvWY\n\t3rpM/xE26+Gg0/LpqhErWHHKUAnQiQx/OFPXdW+x9QRz2flKxErzm5+/NY7WdFZzgYdn\n\t5qNNuRF4LAKe/OUbdFsyyGeYm7V7GiYmsdMS5L/znVxKAIHWW6/90YrP2eU2xPSQhUSS\n\tDDy9LcFgxakutcvg4Gz89z8iWBMwKmeMstX/G75xeyDlaARkWR21b6vOzpErsjpolo8y\n\tJg9WINk9W6hdjUEY/U0A/AG13s5t/zy4xiWk4KPtrRuUTIzwvyKxoObEmjisNXmNoS3T\n\tQ+MQ==",
        "X-Gm-Message-State": "AOAM5317wtt742lV3YFqKd6vcaLTRRltPVljvVDzcdK5nua18JmWj+KW\n\tg7srNFJqKdlAXNCLG+pDq8MlDY8cpEZq2LJtcJALca2qocrRhsd9yQ3T/TS0XQbJaJU+mUZb8Sx\n\tDQGOLsFtvEXo9Ml3QT29rltOTC0LvbFODNmLzB5Xv01GYW03MCphuquLtPKS2Vmm1jsTcSPxfXI\n\ti3jQ7Rs4Jh",
        "X-Received": [
            "by 2002:a5d:64ad:0:b0:204:2f7:b904 with SMTP id\n\tm13-20020a5d64ad000000b0020402f7b904mr15134555wrp.458.1649433618407; \n\tFri, 08 Apr 2022 09:00:18 -0700 (PDT)",
            "by 2002:a5d:64ad:0:b0:204:2f7:b904 with SMTP id\n\tm13-20020a5d64ad000000b0020402f7b904mr15134533wrp.458.1649433618105; \n\tFri, 08 Apr 2022 09:00:18 -0700 (PDT)"
        ],
        "X-Google-Smtp-Source": "ABdhPJyBOtuWHNsNwtGNLZbPr299wti7ddRdUY+8kM+oBz+q7mBI6vzQuusFlApr3/TlNBra31+30w==",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri,  8 Apr 2022 17:00:14 +0100",
        "Message-Id": "<20220408160015.33612-1-ecurtin@redhat.com>",
        "X-Mailer": "git-send-email 2.35.1",
        "MIME-Version": "1.0",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-Originator": "redhat.com",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain; charset=\"US-ASCII\"; x-default=true",
        "Subject": "[libcamera-devel] [PATCH v7 1/2] cam: event_loop: Add timer events\n\tto event loop",
        "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>",
        "From": "Eric Curtin via libcamera-devel <libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Eric Curtin <ecurtin@redhat.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Extend the EventLoop class to support periodic timer events. This can be\nused to run tasks periodically, such as handling the event loop of SDL.\n\nSigned-off-by: Eric Curtin <ecurtin@redhat.com>\n---\n src/cam/event_loop.cpp | 37 +++++++++++++++++++++++++++++++++----\n src/cam/event_loop.h   |  3 +++\n 2 files changed, 36 insertions(+), 4 deletions(-)",
    "diff": "diff --git a/src/cam/event_loop.cpp b/src/cam/event_loop.cpp\nindex e25784c0..1e1a4269 100644\n--- a/src/cam/event_loop.cpp\n+++ b/src/cam/event_loop.cpp\n@@ -60,6 +60,17 @@ void EventLoop::callLater(const std::function<void()> &func)\n \tevent_base_once(base_, -1, EV_TIMEOUT, dispatchCallback, this, nullptr);\n }\n \n+int EventLoop::eventNew(const std::unique_ptr<Event> &event, const int fd, const short events)\n+{\n+\tevent->event_ = event_new(base_, fd, events, &EventLoop::Event::dispatch, event.get());\n+\tif (!event->event_) {\n+\t\tstd::cerr << \"Failed to create event for fd \" << fd << std::endl;\n+\t\treturn -EINVAL;\n+\t}\n+\n+\treturn 0;\n+}\n+\n void EventLoop::addEvent(int fd, EventType type,\n \t\t\t const std::function<void()> &callback)\n {\n@@ -68,10 +79,7 @@ void EventLoop::addEvent(int fd, EventType type,\n \t\t     | (type & Write ? EV_WRITE : 0)\n \t\t     | EV_PERSIST;\n \n-\tevent->event_ = event_new(base_, fd, events, &EventLoop::Event::dispatch,\n-\t\t\t\t  event.get());\n-\tif (!event->event_) {\n-\t\tstd::cerr << \"Failed to create event for fd \" << fd << std::endl;\n+\tif (eventNew(event, fd, events)) {\n \t\treturn;\n \t}\n \n@@ -84,6 +92,27 @@ void EventLoop::addEvent(int fd, EventType type,\n \tevents_.push_back(std::move(event));\n }\n \n+void EventLoop::addTimerEvent(const suseconds_t period,\n+\t\t\t      const std::function<void()> &callback)\n+{\n+\tstd::unique_ptr<Event> event = std::make_unique<Event>(callback);\n+\tif (eventNew(event, -1, EV_PERSIST)) {\n+\t\treturn;\n+\t}\n+\n+\tstruct timeval tv;\n+\ttv.tv_sec = 0;\n+\ttv.tv_usec = period;\n+\n+\tint ret = event_add(event->event_, &tv);\n+\tif (ret < 0) {\n+\t\tstd::cerr << \"Failed to add timer event\" << std::endl;\n+\t\treturn;\n+\t}\n+\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 {\ndiff --git a/src/cam/event_loop.h b/src/cam/event_loop.h\nindex a4613eb2..3d3561e5 100644\n--- a/src/cam/event_loop.h\n+++ b/src/cam/event_loop.h\n@@ -36,6 +36,8 @@ public:\n \n \tvoid addEvent(int fd, EventType type,\n \t\t      const std::function<void()> &handler);\n+\tvoid addTimerEvent(const suseconds_t period,\n+\t\t\t   const std::function<void()> &handler);\n \n private:\n \tstruct Event {\n@@ -60,4 +62,5 @@ private:\n \tstatic void dispatchCallback(evutil_socket_t fd, short flags,\n \t\t\t\t     void *param);\n \tvoid dispatchCall();\n+\tint eventNew(const std::unique_ptr<Event> &event, const int fd, const short events);\n };\n",
    "prefixes": [
        "libcamera-devel",
        "v7",
        "1/2"
    ]
}