Show a patch.

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

{
    "id": 2722,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/2722/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/2722/",
    "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": "<20200122205723.8865-7-laurent.pinchart@ideasonboard.com>",
    "date": "2020-01-22T20:57:16",
    "name": "[libcamera-devel,v2,06/13] libcamera: Define the threading model",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "e8171eab8fa6697fb973c80c386798f5b74acc96",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/2722/mbox/",
    "series": [
        {
            "id": 645,
            "url": "https://patchwork.libcamera.org/api/1.1/series/645/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=645",
            "date": "2020-01-22T20:57:10",
            "name": "Initial libcamera threading model",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/645/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/2722/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/2722/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 C56CC60885\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 22 Jan 2020 21:57:44 +0100 (CET)",
            "from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6FF802E5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 22 Jan 2020 21:57:44 +0100 (CET)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1579726664;\n\tbh=2fgBu15L+B46kfEzGWuKnK8L+KrMOBDQS8P6z3Zp6c4=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=I0Z5X8odMymlTmFl7+nccu8P/1DzMWveUe2UNZoKkZeH9yzdabGW2adZQ6ZjrpM2A\n\tz1NqImNvJUVdsrykX5CGamvIhAS+GPaukwgMQpvGo2pevXTDP8pfsooiXj6YZ/k6GK\n\tMBLS7sSKJkkDdrqGgpH8y1Ldg7Hk6e7kXaXPK9so=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed, 22 Jan 2020 22:57:16 +0200",
        "Message-Id": "<20200122205723.8865-7-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.24.1",
        "In-Reply-To": "<20200122205723.8865-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20200122205723.8865-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 06/13] libcamera: Define the threading\n\tmodel",
        "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": "Wed, 22 Jan 2020 20:57:47 -0000"
    },
    "content": "Document the design of libcamera's threading support, and prepare to\ndocument thread-safety of classes and functions with a doxygen alias\ncommand.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\nChanges since v1:\n\n- Move the thread-reentrancy after thread-objects and thread-signals\n- Add a sentence that was mistakenly part of another patch\n- Fix typos\n---\n Documentation/Doxyfile.in |  4 +-\n src/libcamera/thread.cpp  | 84 +++++++++++++++++++++++++++++++++++++++\n 2 files changed, 87 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/Documentation/Doxyfile.in b/Documentation/Doxyfile.in\nindex 1f746393568a..1c46b04b3f7e 100644\n--- a/Documentation/Doxyfile.in\n+++ b/Documentation/Doxyfile.in\n@@ -239,7 +239,9 @@ TAB_SIZE               = 4\n # newlines (in the resulting output). You can put ^^ in the value part of an\n # alias to insert a newline as if a physical newline was in the original file.\n \n-ALIASES                =\n+ALIASES                = \"context=\\xrefitem context \\\"Thread Safety\\\" \\\"Thread Safety\\\"\"\n+ALIASES               += \"threadbound=\\ref thread-bound \\\"thread-bound\\\"\"\n+ALIASES               += \"threadsafe=\\ref thread-safe \\\"thread-safe\\\"\"\n \n # This tag can be used to specify a number of word-keyword mappings (TCL only).\n # A mapping has the form \"name=value\". For example adding \"class=itcl::class\"\ndiff --git a/src/libcamera/thread.cpp b/src/libcamera/thread.cpp\nindex fe32cd677596..38e01771111d 100644\n--- a/src/libcamera/thread.cpp\n+++ b/src/libcamera/thread.cpp\n@@ -19,6 +19,90 @@\n #include \"log.h\"\n #include \"message.h\"\n \n+/**\n+ * \\page thread Thread Support\n+ *\n+ * libcamera supports multi-threaded applications through a threading model that\n+ * sets precise rules to guarantee thread-safe usage of the API. Additionally,\n+ * libcamera makes internal use of threads, and offers APIs that simplify\n+ * interactions with application threads. Careful compliance with the threading\n+ * model will ensure avoidance of race conditions.\n+ *\n+ * \\section thread-objects Threads and Objects\n+ *\n+ * Instances of the Object class and all its derived classes are thread-aware\n+ * and are bound to the thread they are created in. They are said to *live* in\n+ * a thread, and they interact with the event loop of their thread for the\n+ * purpose of message passing and signal delivery. Messages posted to the\n+ * object with Object::postMessage() will be delivered from the event loop of\n+ * the thread that the object lives in. Signals delivered to the object, unless\n+ * explicitly connected with ConnectionTypeDirect, will also be delivered from\n+ * the object thread's event loop.\n+ *\n+ * All Object instances created by libcamera are bound to an internal thread,\n+ * and applications don't need to provide an event loop to support them. Object\n+ * instances created by applications require an event loop. It is the\n+ * responsibility of applications to provide that event loop, either explicitly\n+ * through CameraManager::setEventDispatcher(), or by running the default event\n+ * loop provided by CameraManager::eventDispatcher() in their main thread. The\n+ * main thread of an application is the one that calls CameraManager::start().\n+ *\n+ * \\section thread-signals Threads and Signals\n+ *\n+ * When sent to a receiver that does not inherit from the Object class, signals\n+ * are delivered synchronously in the thread of the sender. When the receiver\n+ * inherits from the Object class, delivery is by default asynchronous if the\n+ * sender and receiver live in different threads. In that case, the signal is\n+ * posted to the receiver's message queue and will be delivered from the\n+ * receiver's event loop, running in the receiver's thread. This mechanism can\n+ * be overridden by selecting a different connection type when calling\n+ * Signal::connect().\n+ *\n+ * Asynchronous signal delivery is used internally in libcamera, but is also\n+ * available to applications if desired. To use this feature, applications\n+ * shall create receiver classes that inherit from the Object class, and\n+ * provide an event loop to the CameraManager as explained above. Note that\n+ * Object instances created by the application are limited to living in the\n+ * application's main thread. Creating Object instances from another thread of\n+ * an application causes undefined behaviour.\n+ *\n+ * \\section thread-reentrancy Reentrancy and Thread-Safety\n+ *\n+ * Through the documentation, several terms are used to define how classes and\n+ * their member functions can be used from multiple threads.\n+ *\n+ * - A **reentrant** function may be called simultaneously from multiple\n+ *   threads if and only if each invocation uses a different instance of the\n+ *   class. This is the default for all member functions not explictly marked\n+ *   otherwise.\n+ *\n+ * - \\anchor thread-safe A **thread-safe** function may be called\n+ *   simultaneously from multiple threads on the same instance of a class. A\n+ *   thread-safe function is thus reentrant. Thread-safe functions may also be\n+ *   called simultaneously with any other reentrant function of the same class\n+ *   on the same instance.\n+ *\n+ * - \\anchor thread-bound A **thread-bound** function may be called only from\n+ *   the thread that the class instances lives in (see section \\ref\n+ *   thread-objects). For instances of classes that do not derive from the\n+ *   Object class, this is the thread in which the instance was created. A\n+ *   thread-bound function is not thread-safe, and may or may not be reentrant.\n+ *\n+ * Neither reentrancy nor thread-safety, in this context, mean that a function\n+ * may be called simultaneously from the same thread, for instance from a\n+ * callback invoked by the function. This may deadlock and isn't allowed unless\n+ * separately documented.\n+ *\n+ * A class is defined as reentrant, thread-safe or thread-bound if all its\n+ * member functions are reentrant, thread-safe or thread-bound respectively.\n+ * Some member functions may additionally be documented as having additional\n+ * thread-related attributes.\n+ *\n+ * Most classes are reentrant but not thread-safe, as making them fully\n+ * thread-safe would incur locking costs considered prohibitive for the\n+ * expected use cases.\n+ */\n+\n /**\n  * \\file thread.h\n  * \\brief Thread support\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "06/13"
    ]
}