Patch Detail
Show a patch.
GET /api/1.1/patches/2698/?format=api
{ "id": 2698, "url": "https://patchwork.libcamera.org/api/1.1/patches/2698/?format=api", "web_url": "https://patchwork.libcamera.org/patch/2698/", "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": "<20200120002437.6633-12-laurent.pinchart@ideasonboard.com>", "date": "2020-01-20T00:24:29", "name": "[libcamera-devel,11/19] libcamera: Document thread-safety attributes of core classes", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "61cdc5496eff2616b28824520f085904f2332c9a", "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/2698/mbox/", "series": [ { "id": 641, "url": "https://patchwork.libcamera.org/api/1.1/series/641/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=641", "date": "2020-01-20T00:24:19", "name": "Initial libcamera threading model", "version": 1, "mbox": "https://patchwork.libcamera.org/series/641/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/2698/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/2698/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 D1AF6607F6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 20 Jan 2020 01:24:46 +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 3C3631176\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 20 Jan 2020 01:24:46 +0100 (CET)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1579479886;\n\tbh=JIkyqxH76PuuyQ9kB4LgACPD2JIYVU9OciQYvnKIeNY=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=gQ+AU2yXKYGxFX+LCqepELUvgEDMPN+e+mYZr78GshpXG2MN1o92jcMwsDUAPU4Oh\n\tgwY0Xa5TjOiPlskF7EJ4ewlQnff/cJdp+pyr3k33ehcILCFIr6PfKaFWtYt202bQX5\n\tc8vCXBicB5kJqoinyyFgRC6TLIJrOdbz7y+xVYUI=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 20 Jan 2020 02:24:29 +0200", "Message-Id": "<20200120002437.6633-12-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.24.1", "In-Reply-To": "<20200120002437.6633-1-laurent.pinchart@ideasonboard.com>", "References": "<20200120002437.6633-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 11/19] libcamera: Document thread-safety\n\tattributes of core classes", "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": "Mon, 20 Jan 2020 00:24:47 -0000" }, "content": "Define the thread-safety attributes of the classes and methods that are\neither thread-safe or thread-bound. The CameraManager, Camera and\nPipelineHandler will be addressed separately.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/device_enumerator.cpp | 2 ++\n src/libcamera/event_notifier.cpp | 2 ++\n src/libcamera/ipc_unixsocket.cpp | 2 ++\n src/libcamera/object.cpp | 10 ++++++++--\n src/libcamera/thread.cpp | 6 +++++-\n src/libcamera/timer.cpp | 20 ++++++++++++--------\n src/libcamera/v4l2_videodevice.cpp | 2 ++\n 7 files changed, 33 insertions(+), 11 deletions(-)", "diff": "diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp\nindex a8b5c90f5a5d..64cdc132308a 100644\n--- a/src/libcamera/device_enumerator.cpp\n+++ b/src/libcamera/device_enumerator.cpp\n@@ -190,6 +190,8 @@ DeviceEnumerator::~DeviceEnumerator()\n * with a warning message logged, without returning an error. Only errors that\n * prevent enumeration altogether shall be fatal.\n *\n+ * \\context This function is \\threadbound.\n+ *\n * \\return 0 on success or a negative error code otherwise\n */\n \ndiff --git a/src/libcamera/event_notifier.cpp b/src/libcamera/event_notifier.cpp\nindex 4326b0b413e2..a9be686f79ae 100644\n--- a/src/libcamera/event_notifier.cpp\n+++ b/src/libcamera/event_notifier.cpp\n@@ -99,6 +99,8 @@ EventNotifier::~EventNotifier()\n *\n * This function enables or disables the notifier. A disabled notifier ignores\n * events and does not emit the \\ref activated signal.\n+ *\n+ * \\context This function is \\threadbound.\n */\n void EventNotifier::setEnabled(bool enable)\n {\ndiff --git a/src/libcamera/ipc_unixsocket.cpp b/src/libcamera/ipc_unixsocket.cpp\nindex eb1a50239188..6e5cab894a93 100644\n--- a/src/libcamera/ipc_unixsocket.cpp\n+++ b/src/libcamera/ipc_unixsocket.cpp\n@@ -62,6 +62,8 @@ LOG_DEFINE_CATEGORY(IPCUnixSocket)\n * communication method. The remote side then instantiates a socket, and binds\n * it to the other side by passing the file descriptor to bind(). At that point\n * the channel is operation and communication is bidirectional and symmmetrical.\n+ *\n+ * \\context This class is \\threadbound.\n */\n \n IPCUnixSocket::IPCUnixSocket()\ndiff --git a/src/libcamera/object.cpp b/src/libcamera/object.cpp\nindex f2a8be172547..99c3bf9a709b 100644\n--- a/src/libcamera/object.cpp\n+++ b/src/libcamera/object.cpp\n@@ -110,6 +110,8 @@ Object::~Object()\n * Messages are delivered through the thread's event loop. If the thread is not\n * running its event loop the message will not be delivered until the event\n * loop gets started.\n+ *\n+ * \\context This function is \\threadsafe.\n */\n void Object::postMessage(std::unique_ptr<Message> msg)\n {\n@@ -162,6 +164,8 @@ void Object::message(Message *msg)\n * are passed untouched. The caller shall ensure that any pointer argument\n * remains valid until the method is invoked.\n *\n+ * \\context This function is \\threadsafe.\n+ *\n * \\return For connection types ConnectionTypeDirect and\n * ConnectionTypeBlocking, return the return value of the invoked method. For\n * connection type ConnectionTypeQueued, return a default-constructed R value.\n@@ -170,6 +174,7 @@ void Object::message(Message *msg)\n /**\n * \\fn Object::thread()\n * \\brief Retrieve the thread the object is bound to\n+ * \\context This function is \\threadsafe.\n * \\return The thread the object is bound to\n */\n \n@@ -178,8 +183,7 @@ void Object::message(Message *msg)\n * \\param[in] thread The target thread\n *\n * This method moves the object and all its children from the current thread to\n- * the new \\a thread. It shall be called from the thread in which the object\n- * currently lives, otherwise the behaviour is undefined.\n+ * the new \\a thread.\n *\n * Before the object is moved, a Message::ThreadMoveMessage message is sent to\n * it. The message() method can be reimplement in derived classes to be notified\n@@ -187,6 +191,8 @@ void Object::message(Message *msg)\n *\n * Moving an object that has a parent is not allowed, and causes undefined\n * behaviour.\n+ *\n+ * \\context This function is thread-bound.\n */\n void Object::moveToThread(Thread *thread)\n {\ndiff --git a/src/libcamera/thread.cpp b/src/libcamera/thread.cpp\nindex c1698d469a6c..0cf6ff691315 100644\n--- a/src/libcamera/thread.cpp\n+++ b/src/libcamera/thread.cpp\n@@ -40,7 +40,9 @@\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.\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@@ -220,6 +222,8 @@ ThreadData *ThreadData::current()\n * called. A custom event dispatcher may be installed with\n * setEventDispatcher(), otherwise a poll-based event dispatcher is used. This\n * behaviour can be overriden by overloading the run() method.\n+ *\n+ * \\context This class is \\threadsafe.\n */\n \n /**\ndiff --git a/src/libcamera/timer.cpp b/src/libcamera/timer.cpp\nindex 4c68883204e8..24da51524efb 100644\n--- a/src/libcamera/timer.cpp\n+++ b/src/libcamera/timer.cpp\n@@ -67,16 +67,18 @@ Timer::~Timer()\n * \\brief Start or restart the timer with a timeout of \\a msec\n * \\param[in] msec The timer duration in milliseconds\n *\n- * This method shall be called from the thread the timer is associated with. If\n- * the timer is already running it will be stopped and restarted.\n+ * If the timer is already running it will be stopped and restarted.\n+ *\n+ * \\context This function is \\threadbound.\n */\n \n /**\n * \\brief Start or restart the timer with a timeout of \\a duration\n * \\param[in] duration The timer duration in milliseconds\n *\n- * This method shall be called from the thread the timer is associated with. If\n- * the timer is already running it will be stopped and restarted.\n+ * If the timer is already running it will be stopped and restarted.\n+ *\n+ * \\context This function is \\threadbound.\n */\n void Timer::start(std::chrono::milliseconds duration)\n {\n@@ -87,8 +89,9 @@ void Timer::start(std::chrono::milliseconds duration)\n * \\brief Start or restart the timer with a \\a deadline\n * \\param[in] deadline The timer deadline\n *\n- * This method shall be called from the thread the timer is associated with. If\n- * the timer is already running it will be stopped and restarted.\n+ * If the timer is already running it will be stopped and restarted.\n+ *\n+ * \\context This function is \\threadbound.\n */\n void Timer::start(std::chrono::steady_clock::time_point deadline)\n {\n@@ -115,8 +118,9 @@ void Timer::start(std::chrono::steady_clock::time_point deadline)\n * After this function returns the timer is guaranteed not to emit the\n * \\ref timeout signal.\n *\n- * This method shall be called from the thread the timer is associated with. If\n- * the timer is not running this function performs no operation.\n+ * If the timer is not running this function performs no operation.\n+ *\n+ * \\context This function is \\threadbound.\n */\n void Timer::stop()\n {\ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex 51be1dcd7fff..cb166c795abd 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -404,6 +404,8 @@ const std::string V4L2DeviceFormat::toString() const\n *\n * Upon destruction any device left open will be closed, and any resources\n * released.\n+ *\n+ * \\context This class is \\threadbound.\n */\n \n /**\n", "prefixes": [ "libcamera-devel", "11/19" ] }