{"id":2280,"url":"https://patchwork.libcamera.org/api/1.1/patches/2280/?format=json","web_url":"https://patchwork.libcamera.org/patch/2280/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20191028104913.14985-8-laurent.pinchart@ideasonboard.com>","date":"2019-10-28T10:49:11","name":"[libcamera-devel,v2,7/9] libcamera: object: Add connection type parameter to invokeMethod()","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"b3764ece3adf9e986dc40e8dc752cf12567ae452","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/2280/mbox/","series":[{"id":562,"url":"https://patchwork.libcamera.org/api/1.1/series/562/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=562","date":"2019-10-28T10:49:04","name":"Add support for blocking method invocation","version":2,"mbox":"https://patchwork.libcamera.org/series/562/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/2280/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/2280/checks/","tags":{},"headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id ED76B6139C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Oct 2019 11:49:26 +0100 (CET)","from pendragon.ideasonboard.com (unknown [91.217.168.176])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A8F369C2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Oct 2019 11:49:26 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1572259766;\n\tbh=iVo/C52z3aQ/4H+6fm7BOXDR4iRuOX3VIw/M79icSuA=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=ksLxwzlFTosu1Nz+fYleRGjRxpxWnp0KFGjua23GiyqoUJjZ54PSFqOylmWFGW+hD\n\tuLnScqKDURkyi5Ej6j2bpu1VvUgQozRswpUVreZcSOSdMYw2LwQ1HC8N3hGGfToxLk\n\tE3EEG9W8axe30ripGNq12/mmoDfqOgxvDLgC1cvc=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 28 Oct 2019 12:49:11 +0200","Message-Id":"<20191028104913.14985-8-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.23.0","In-Reply-To":"<20191028104913.14985-1-laurent.pinchart@ideasonboard.com>","References":"<20191028104913.14985-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 7/9] libcamera: object: Add connection\n\ttype parameter to invokeMethod()","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, 28 Oct 2019 10:49:28 -0000"},"content":"From: Jacopo Mondi <jacopo@jmondi.org>\n\nAllow specifying a different connection type than ConnectionTypeQueued\nfor Object::invokeMethod().\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/object.h       |  5 ++---\n src/android/camera_proxy.cpp     |  3 ++-\n src/libcamera/event_notifier.cpp |  3 ++-\n src/libcamera/object.cpp         |  9 +++++----\n src/libcamera/timer.cpp          |  3 ++-\n test/object-invoke.cpp           | 14 ++++++++------\n 6 files changed, 21 insertions(+), 16 deletions(-)","diff":"diff --git a/include/libcamera/object.h b/include/libcamera/object.h\nindex 603a229288c2..91b56596c9db 100644\n--- a/include/libcamera/object.h\n+++ b/include/libcamera/object.h\n@@ -30,12 +30,11 @@ public:\n \tvoid postMessage(std::unique_ptr<Message> msg);\n \n \ttemplate<typename T, typename... Args, typename std::enable_if<std::is_base_of<Object, T>::value>::type * = nullptr>\n-\tvoid invokeMethod(void (T::*func)(Args...), Args... args)\n+\tvoid invokeMethod(void (T::*func)(Args...), ConnectionType type, Args... args)\n \t{\n \t\tT *obj = static_cast<T *>(this);\n \t\tBoundMethodBase *method =\n-\t\t\tnew BoundMemberMethod<T, Args...>(obj, this, func,\n-\t\t\t\t\t\t\t  ConnectionTypeQueued);\n+\t\t\tnew BoundMemberMethod<T, Args...>(obj, this, func, type);\n \t\tvoid *pack = new typename BoundMemberMethod<T, Args...>::PackType{ args... };\n \n \t\tmethod->activatePack(pack, true);\ndiff --git a/src/android/camera_proxy.cpp b/src/android/camera_proxy.cpp\nindex 4f5c0a024903..43e1e1c3af53 100644\n--- a/src/android/camera_proxy.cpp\n+++ b/src/android/camera_proxy.cpp\n@@ -187,6 +187,7 @@ int CameraProxy::processCaptureRequest(camera3_capture_request_t *request)\n \n void CameraProxy::threadRpcCall(ThreadRpc &rpcRequest)\n {\n-\tcameraDevice_->invokeMethod(&CameraDevice::call, &rpcRequest);\n+\tcameraDevice_->invokeMethod(&CameraDevice::call, ConnectionTypeQueued,\n+\t\t\t\t    &rpcRequest);\n \trpcRequest.waitDelivery();\n }\ndiff --git a/src/libcamera/event_notifier.cpp b/src/libcamera/event_notifier.cpp\nindex 687969b0a8d1..4326b0b413e2 100644\n--- a/src/libcamera/event_notifier.cpp\n+++ b/src/libcamera/event_notifier.cpp\n@@ -128,7 +128,8 @@ void EventNotifier::message(Message *msg)\n \tif (msg->type() == Message::ThreadMoveMessage) {\n \t\tif (enabled_) {\n \t\t\tsetEnabled(false);\n-\t\t\tinvokeMethod(&EventNotifier::setEnabled, true);\n+\t\t\tinvokeMethod(&EventNotifier::setEnabled,\n+\t\t\t\t     ConnectionTypeQueued, true);\n \t\t}\n \t}\n \ndiff --git a/src/libcamera/object.cpp b/src/libcamera/object.cpp\nindex 509b2ebac537..db2c6f68fbc8 100644\n--- a/src/libcamera/object.cpp\n+++ b/src/libcamera/object.cpp\n@@ -139,14 +139,15 @@ void Object::message(Message *msg)\n }\n \n /**\n- * \\fn void Object::invokeMethod(void (T::*func)(Args...), Args... args)\n+ * \\fn void Object::invokeMethod()\n  * \\brief Invoke a method asynchronously on an Object instance\n  * \\param[in] func The object method to invoke\n+ * \\param[in] type Connection type for method invocation\n  * \\param[in] args The method arguments\n  *\n- * This method invokes the member method \\a func when control returns to the\n- * event loop of the object's thread. The method is executed in the object's\n- * thread with arguments \\a args.\n+ * This method invokes the member method \\a func with arguments \\a args, based\n+ * on the connection \\a type. Depending on the type, the method will be called\n+ * synchronously in the same thread or asynchronously in the object's thread.\n  *\n  * Arguments \\a args passed by value or reference are copied, while pointers\n  * are passed untouched. The caller shall ensure that any pointer argument\ndiff --git a/src/libcamera/timer.cpp b/src/libcamera/timer.cpp\nindex ddb20954afa7..4c68883204e8 100644\n--- a/src/libcamera/timer.cpp\n+++ b/src/libcamera/timer.cpp\n@@ -170,7 +170,8 @@ void Timer::message(Message *msg)\n \tif (msg->type() == Message::ThreadMoveMessage) {\n \t\tif (isRunning()) {\n \t\t\tunregisterTimer();\n-\t\t\tinvokeMethod(&Timer::registerTimer);\n+\t\t\tinvokeMethod(&Timer::registerTimer,\n+\t\t\t\t     ConnectionTypeQueued);\n \t\t}\n \t}\n \ndiff --git a/test/object-invoke.cpp b/test/object-invoke.cpp\nindex 37a274402e6d..f6ae2604db76 100644\n--- a/test/object-invoke.cpp\n+++ b/test/object-invoke.cpp\n@@ -64,10 +64,11 @@ protected:\n \t\tInvokedObject object;\n \n \t\t/*\n-\t\t * Test that method invocation in the same thread goes through\n-\t\t * the event dispatcher.\n+\t\t * Test that queued method invocation in the same thread goes\n+\t\t * through the event dispatcher.\n \t\t */\n-\t\tobject.invokeMethod(&InvokedObject::method, 42);\n+\t\tobject.invokeMethod(&InvokedObject::method,\n+\t\t\t\t    ConnectionTypeQueued, 42);\n \n \t\tif (object.status() != InvokedObject::NoCall) {\n \t\t\tcerr << \"Method not invoked asynchronously\" << endl;\n@@ -93,15 +94,16 @@ protected:\n \t\t}\n \n \t\t/*\n-\t\t * Move the object to a thread and verify that the method is\n-\t\t * delivered in the correct thread.\n+\t\t * Move the object to a thread and verify that auto method\n+\t\t * invocation is delivered in the correct thread.\n \t\t */\n \t\tobject.reset();\n \t\tobject.moveToThread(&thread_);\n \n \t\tthread_.start();\n \n-\t\tobject.invokeMethod(&InvokedObject::method, 42);\n+\t\tobject.invokeMethod(&InvokedObject::method,\n+\t\t\t\t    ConnectionTypeAuto, 42);\n \t\tthis_thread::sleep_for(chrono::milliseconds(100));\n \n \t\tswitch (object.status()) {\n","prefixes":["libcamera-devel","v2","7/9"]}