Show a patch.

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

{
    "id": 2112,
    "url": "https://patchwork.libcamera.org/api/patches/2112/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/2112/",
    "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": "<20191006053226.8976-8-laurent.pinchart@ideasonboard.com>",
    "date": "2019-10-06T05:32:24",
    "name": "[libcamera-devel,7/9] test: timer-thread: Test starting a timer from another thread",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "a92accc0c2e6604cceae9dfe479692449ea41382",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/2112/mbox/",
    "series": [
        {
            "id": 522,
            "url": "https://patchwork.libcamera.org/api/series/522/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=522",
            "date": "2019-10-06T05:32:17",
            "name": "Timer fixes and enhancements",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/522/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/2112/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/2112/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<laurent.pinchart@ideasonboard.com>",
        "Received": [
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D1FB961565\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun,  6 Oct 2019 07:32:39 +0200 (CEST)",
            "from pendragon.ideasonboard.com\n\t(modemcable151.96-160-184.mc.videotron.ca [184.160.96.151])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 467A073E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun,  6 Oct 2019 07:32:39 +0200 (CEST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1570339959;\n\tbh=n0oxRCU3o0jCj1C0jnXAE4by/bnEtj/Wxf0C+S2Ptg0=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=jn7WA6NG8yYyObSqXOBzwt03IgSNyQMGwkXfyGN9hN6oBk6Ad2O1qrluQZXRJC6uo\n\tzPDx+tr3DAvFxp6LdfCox5FwWTPg8Mb6kw6WUr5l0dzodaAYLBlVRMUZewxEst04B4\n\t+IdQmLmLvbTp9rLr691UjF8ue7sg6+fkjUObu5OU=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sun,  6 Oct 2019 08:32:24 +0300",
        "Message-Id": "<20191006053226.8976-8-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.21.0",
        "In-Reply-To": "<20191006053226.8976-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20191006053226.8976-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 7/9] test: timer-thread: Test starting a\n\ttimer from another thread",
        "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>",
        "X-List-Received-Date": "Sun, 06 Oct 2019 05:32:40 -0000"
    },
    "content": "Timers can't be started from another thread. Ensure that attempting to\ndo so fails.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n test/timer-thread.cpp | 58 ++++++++++++++++++++++++++++++++++---------\n 1 file changed, 46 insertions(+), 12 deletions(-)",
    "diff": "diff --git a/test/timer-thread.cpp b/test/timer-thread.cpp\nindex 5c1b4ac4a401..32853b4e80ef 100644\n--- a/test/timer-thread.cpp\n+++ b/test/timer-thread.cpp\n@@ -8,6 +8,7 @@\n #include <chrono>\n #include <iostream>\n \n+#include <libcamera/event_dispatcher.h>\n #include <libcamera/timer.h>\n \n #include \"test.h\"\n@@ -26,6 +27,12 @@ public:\n \t\ttimer_.start(100);\n \t}\n \n+\tvoid restart()\n+\t{\n+\t\ttimeout_ = false;\n+\t\ttimer_.start(100);\n+\t}\n+\n \tbool timeout() const\n \t{\n \t\treturn timeout_;\n@@ -44,29 +51,56 @@ private:\n class TimerThreadTest : public Test\n {\n protected:\n+\tint init()\n+\t{\n+\t\tthread_.start();\n+\t\ttimeout_.moveToThread(&thread_);\n+\n+\t\treturn TestPass;\n+\t}\n+\n \tint run()\n \t{\n-\t\tThread thread;\n-\t\tthread.start();\n+\t\t/*\n+\t\t * Test that the timer expires and emits the timeout signal in\n+\t\t * the thread it belongs to.\n+\t\t */\n+\t\tthis_thread::sleep_for(chrono::milliseconds(200));\n \n-\t\tTimeoutHandler timeout;\n-\t\ttimeout.moveToThread(&thread);\n-\n-\t\tthis_thread::sleep_for(chrono::milliseconds(100));\n-\n-\t\t/* Must stop thread before destroying timeout. */\n-\t\tthread.exit(0);\n-\t\tthread.wait();\n-\n-\t\tif (!timeout.timeout()) {\n+\t\tif (!timeout_.timeout()) {\n \t\t\tcout << \"Timer expiration test failed\" << endl;\n \t\t\treturn TestFail;\n \t\t}\n \n+\t\t/*\n+\t\t * Test that starting the timer from another thread fails. We\n+\t\t * need to interrupt the event dispatcher to make sure we don't\n+\t\t * succeed simply because the event dispatcher hasn't noticed\n+\t\t * the timer restart.\n+\t\t */\n+\t\ttimeout_.restart();\n+\t\tthread_.eventDispatcher()->interrupt();\n+\n+\t\tthis_thread::sleep_for(chrono::milliseconds(200));\n+\n+\t\tif (timeout_.timeout()) {\n+\t\t\tcout << \"Timer restart test failed\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n \t\treturn TestPass;\n \t}\n \n+\tvoid cleanup()\n+\t{\n+\t\t/* Must stop thread before destroying timeout. */\n+\t\tthread_.exit(0);\n+\t\tthread_.wait();\n+\t}\n+\n private:\n+\tTimeoutHandler timeout_;\n+\tThread thread_;\n };\n \n TEST_REGISTER(TimerThreadTest)\n",
    "prefixes": [
        "libcamera-devel",
        "7/9"
    ]
}