Show a patch.

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

{
    "id": 9083,
    "url": "https://patchwork.libcamera.org/api/patches/9083/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/9083/",
    "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": "<20200731105335.62014-2-email@uajain.com>",
    "date": "2020-07-31T10:53:41",
    "name": "[libcamera-devel,v2,1/3] libcamera: thread: Support selective message dispatch to thread",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "de10546d4de5d1a04a9bf0b794169795f4e2f229",
    "submitter": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/people/1/?format=api",
        "name": "Umang Jain",
        "email": "email@uajain.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/9083/mbox/",
    "series": [
        {
            "id": 1167,
            "url": "https://patchwork.libcamera.org/api/series/1167/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1167",
            "date": "2020-07-31T10:53:41",
            "name": "Add Object::deleteLater() support",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/1167/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/9083/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/9083/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 761FBBD86F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 31 Jul 2020 10:53:45 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B5E5161DD8;\n\tFri, 31 Jul 2020 12:53:44 +0200 (CEST)",
            "from o1.f.az.sendgrid.net (o1.f.az.sendgrid.net [208.117.55.132])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C1E4060396\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 31 Jul 2020 12:53:42 +0200 (CEST)",
            "by filterdrecv-p3mdw1-7ff865655c-g882x with SMTP id\n\tfilterdrecv-p3mdw1-7ff865655c-g882x-20-5F23F835-1\n\t2020-07-31 10:53:41.138588816 +0000 UTC m=+146250.616757875",
            "from mail.uajain.com (unknown)\n\tby ismtpd0004p1hnd1.sendgrid.net (SG) with ESMTP id\n\tBWbqALB4RgC8qD5ODvWMTA for <libcamera-devel@lists.libcamera.org>;\n\tFri, 31 Jul 2020 10:53:40.725 +0000 (UTC)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=uajain.com header.i=@uajain.com\n\theader.b=\"N2tiQ0MU\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=uajain.com;\n\th=from:subject:in-reply-to:references:mime-version:to:cc:\n\tcontent-transfer-encoding:content-type;\n\ts=s1; bh=bMNOnkEkTHpbNEBGYnD0orvQ1VUtKvvk0NQGieyHQHA=;\n\tb=N2tiQ0MUCGJ7NWGtRrofpBsRcUB8/QceckFKu/bnSgWqGyvwPJSH28XRzNfwXHKmQxvU\n\tSplbkgTS4xpyq1vGzys+qKfSZZ7wyOWIr+KOMBFRssmugd9rxzIkiaYJYscl95zDsWpuh2\n\tICRn/DJYCetXoU9tIFkGt36Amm/sVEKfU=",
        "From": "Umang Jain <email@uajain.com>",
        "Date": "Fri, 31 Jul 2020 10:53:41 +0000 (UTC)",
        "Message-Id": "<20200731105335.62014-2-email@uajain.com>",
        "In-Reply-To": "<20200731105335.62014-1-email@uajain.com>",
        "References": "<20200731105335.62014-1-email@uajain.com>",
        "Mime-Version": "1.0",
        "X-SG-EID": "1Q40EQ7YGir8a9gjSIAdTjhngY657NMk9ckeo4dbHZDiOpywc/L3L9rFqlwE4KPcofpXQ1KwJPJayd5tGsU1eL8pT6L5XI068+X2BjFsmbU12v7JkpGTHOEJUQjc1upjdOPJ81lysMBHJkG1DANMDVGdCJzM3BkM9m2bkrfHzYmQuH0hngP3RhjlZHRa7NXZiHEUQo0a9R+kMNa2sttZ40V6npMTrTxkX9O5/ODAFxkiJ37InOB5O7WRIz4jnoyQyAceSy+WBh1G6StX1+bhzg==",
        "To": "libcamera-devel@lists.libcamera.org",
        "Subject": "[libcamera-devel] [PATCH v2 1/3] libcamera: thread: Support\n\tselective message dispatch to 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>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Extend the current dispatchMessages() to support dispatching of\nselective messsages according to the Message::Type passed in\nthe function argument. dispatchMessages() can now be called\nexplicitly to force deliver selected type's message to the\nthread for processing (typically when event loop is not\nrunning).\n\nAdd a helper Message::Type::CatchAll message type to deliver every\nmessage posted to the thread.\n\nSigned-off-by: Umang Jain <email@uajain.com>\n---\n include/libcamera/internal/message.h    |  1 +\n include/libcamera/internal/thread.h     |  3 +-\n src/libcamera/event_dispatcher_poll.cpp |  2 +-\n src/libcamera/message.cpp               |  2 ++\n src/libcamera/thread.cpp                | 47 ++++++++++++++++++-------\n 5 files changed, 40 insertions(+), 15 deletions(-)",
    "diff": "diff --git a/include/libcamera/internal/message.h b/include/libcamera/internal/message.h\nindex 92ea64a..b8d9866 100644\n--- a/include/libcamera/internal/message.h\n+++ b/include/libcamera/internal/message.h\n@@ -25,6 +25,7 @@ public:\n \t\tNone = 0,\n \t\tInvokeMessage = 1,\n \t\tThreadMoveMessage = 2,\n+\t\tCatchAll = 999,\n \t\tUserMessage = 1000,\n \t};\n \ndiff --git a/include/libcamera/internal/thread.h b/include/libcamera/internal/thread.h\nindex 7b59e58..1dfeb72 100644\n--- a/include/libcamera/internal/thread.h\n+++ b/include/libcamera/internal/thread.h\n@@ -14,6 +14,7 @@\n \n #include <libcamera/signal.h>\n \n+#include \"libcamera/internal/message.h\"\n #include \"libcamera/internal/utils.h\"\n \n namespace libcamera {\n@@ -47,7 +48,7 @@ public:\n \tEventDispatcher *eventDispatcher();\n \tvoid setEventDispatcher(std::unique_ptr<EventDispatcher> dispatcher);\n \n-\tvoid dispatchMessages();\n+\tvoid dispatchMessages(Message::Type type);\n \n protected:\n \tint exec();\ndiff --git a/src/libcamera/event_dispatcher_poll.cpp b/src/libcamera/event_dispatcher_poll.cpp\nindex 9ab85da..b9fabf8 100644\n--- a/src/libcamera/event_dispatcher_poll.cpp\n+++ b/src/libcamera/event_dispatcher_poll.cpp\n@@ -146,7 +146,7 @@ void EventDispatcherPoll::processEvents()\n {\n \tint ret;\n \n-\tThread::current()->dispatchMessages();\n+\tThread::current()->dispatchMessages(Message::Type::CatchAll);\n \n \t/* Create the pollfd array. */\n \tstd::vector<struct pollfd> pollfds;\ndiff --git a/src/libcamera/message.cpp b/src/libcamera/message.cpp\nindex e9b3e73..e462f90 100644\n--- a/src/libcamera/message.cpp\n+++ b/src/libcamera/message.cpp\n@@ -49,6 +49,8 @@ std::atomic_uint Message::nextUserType_{ Message::UserMessage };\n  * \\brief Asynchronous method invocation across threads\n  * \\var Message::ThreadMoveMessage\n  * \\brief Object is being moved to a different thread\n+ * \\var Message::CatchAll\n+ * \\brief Helper to match message of any type\n  * \\var Message::UserMessage\n  * \\brief First value available for user-defined messages\n  */\ndiff --git a/src/libcamera/thread.cpp b/src/libcamera/thread.cpp\nindex d1750d7..d3a5f81 100644\n--- a/src/libcamera/thread.cpp\n+++ b/src/libcamera/thread.cpp\n@@ -552,26 +552,47 @@ void Thread::removeMessages(Object *receiver)\n }\n \n /**\n- * \\brief Dispatch all posted messages for this thread\n+ * \\brief Dispatch posted messages for this thread as per \\a type Message::Type.\n+ *  Pass Message::Type::CatchAll to dispatch every posted message posted for\n+ *  this thread.\n  */\n-void Thread::dispatchMessages()\n+void Thread::dispatchMessages(Message::Type type)\n {\n \tMutexLocker locker(data_->messages_.mutex_);\n \n-\twhile (!data_->messages_.list_.empty()) {\n-\t\tstd::unique_ptr<Message> msg = std::move(data_->messages_.list_.front());\n-\t\tdata_->messages_.list_.pop_front();\n-\t\tif (!msg)\n-\t\t\tcontinue;\n+\tif (type == Message::Type::CatchAll) {\n+\t\twhile (!data_->messages_.list_.empty()) {\n+\t\t\tstd::unique_ptr<Message> msg =\n+\t\t\t\tstd::move(data_->messages_.list_.front());\n+\t\t\tdata_->messages_.list_.pop_front();\n+\t\t\tif (!msg)\n+\t\t\t\tcontinue;\n \n-\t\tObject *receiver = msg->receiver_;\n-\t\tASSERT(data_ == receiver->thread()->data_);\n+\t\t\tObject *receiver = msg->receiver_;\n+\t\t\tASSERT(data_ == receiver->thread()->data_);\n \n-\t\treceiver->pendingMessages_--;\n+\t\t\treceiver->pendingMessages_--;\n \n-\t\tlocker.unlock();\n-\t\treceiver->message(msg.get());\n-\t\tlocker.lock();\n+\t\t\tlocker.unlock();\n+\t\t\treceiver->message(msg.get());\n+\t\t\tlocker.lock();\n+\t\t}\n+\t} else {\n+\t\tfor (std::unique_ptr<Message> &msg : data_->messages_.list_) {\n+\t\t\tif (!msg)\n+\t\t\t\tcontinue;\n+\n+\t\t\tif (msg->type() == type) {\n+\t\t\t\tstd::unique_ptr<Message> message = std::move(msg);\n+\t\t\t\tObject *receiver = message->receiver_;\n+\t\t\t\tASSERT(data_ == receiver->thread()->data_);\n+\t\t\t\treceiver->pendingMessages_--;\n+\n+\t\t\t\tlocker.unlock();\n+\t\t\t\treceiver->message(message.get());\n+\t\t\t\tlocker.lock();\n+\t\t\t}\n+\t\t}\n \t}\n }\n \n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "1/3"
    ]
}