{"id":2233,"url":"https://patchwork.libcamera.org/api/patches/2233/?format=json","web_url":"https://patchwork.libcamera.org/patch/2233/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20191027203335.26888-3-jacopo@jmondi.org>","date":"2019-10-27T20:33:31","name":"[libcamera-devel,2/6] libcamera: object: Invoke method with invokeType","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"ceef0c3e813e32602bfaf8cc8de89ceaac6e7d9a","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":{"id":15,"url":"https://patchwork.libcamera.org/api/users/15/?format=json","username":"jmondi","first_name":"Jacopo","last_name":"Mondi","email":"jacopo@jmondi.org"},"mbox":"https://patchwork.libcamera.org/patch/2233/mbox/","series":[{"id":558,"url":"https://patchwork.libcamera.org/api/series/558/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=558","date":"2019-10-27T20:33:29","name":"Add support for blocking method invocation","version":1,"mbox":"https://patchwork.libcamera.org/series/558/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/2233/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/2233/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net\n\t[217.70.183.198])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 225886017C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 27 Oct 2019 21:31:49 +0100 (CET)","from uno.localdomain (143.121.2.93.rev.sfr.net [93.2.121.143])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay6-d.mail.gandi.net (Postfix) with ESMTPSA id B3F46C0002;\n\tSun, 27 Oct 2019 20:31:48 +0000 (UTC)"],"X-Originating-IP":"93.2.121.143","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Sun, 27 Oct 2019 21:33:31 +0100","Message-Id":"<20191027203335.26888-3-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.23.0","In-Reply-To":"<20191027203335.26888-1-jacopo@jmondi.org>","References":"<20191027203335.26888-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 2/6] libcamera: object: Invoke method with\n\tinvokeType","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, 27 Oct 2019 20:31:49 -0000"},"content":"Add the method invocation type to Object::invokeMethod() operation.\nThe additional type parameter will be used when delivering\nInvokeMessages and decide if the caller should block waiting for\nreception or the message or return immediately.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n include/libcamera/object.h       | 6 +++---\n src/android/camera_proxy.cpp     | 3 ++-\n src/libcamera/event_notifier.cpp | 3 ++-\n src/libcamera/object.cpp         | 5 +++--\n src/libcamera/timer.cpp          | 2 +-\n test/object-invoke.cpp           | 5 +++--\n 6 files changed, 14 insertions(+), 10 deletions(-)","diff":"diff --git a/include/libcamera/object.h b/include/libcamera/object.h\nindex 017d3f8aa915..be07611c25c6 100644\n--- a/include/libcamera/object.h\n+++ b/include/libcamera/object.h\n@@ -37,13 +37,13 @@ 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...), InvocationType type, Args... args)\n \t{\n \t\tT *obj = static_cast<T *>(this);\n \t\tBoundMethodBase *method = new BoundMemberMethod<T, Args...>(obj, this, func);\n \t\tvoid *pack = new typename BoundMemberMethod<T, Args...>::PackType{ args... };\n \n-\t\tinvokeMethod(method, pack);\n+\t\tinvokeMethod(method, type, pack);\n \t}\n \n \tThread *thread() const { return thread_; }\n@@ -60,7 +60,7 @@ private:\n \tfriend class BoundMethodBase;\n \tfriend class Thread;\n \n-\tvoid invokeMethod(BoundMethodBase *method, void *pack);\n+\tvoid invokeMethod(BoundMethodBase *method, InvocationType type, void *pack);\n \n \tvoid notifyThreadMove();\n \ndiff --git a/src/android/camera_proxy.cpp b/src/android/camera_proxy.cpp\nindex 4f5c0a024903..5f8428cfddfb 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, InvocationTypeQueued,\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..75456b4bb15e 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     InvocationTypeAuto, true);\n \t\t}\n \t}\n \ndiff --git a/src/libcamera/object.cpp b/src/libcamera/object.cpp\nindex 82df3893d052..d7c9ac970d1c 100644\n--- a/src/libcamera/object.cpp\n+++ b/src/libcamera/object.cpp\n@@ -160,9 +160,10 @@ void Object::message(Message *msg)\n }\n \n /**\n- * \\fn void Object::invokeMethod(void (T::*func)(Args...), Args... args)\n+ * \\fn void Object::invokeMethod(void (T::*func)(Args...), InvocationType type, Args... args)\n  * \\brief Invoke a method asynchronously on an Object instance\n  * \\param[in] func The object method to invoke\n+ * \\param[in] type The method invocation type\n  * \\param[in] args The method arguments\n  *\n  * This method invokes the member method \\a func when control returns to the\n@@ -174,7 +175,7 @@ void Object::message(Message *msg)\n  * remains valid until the method is invoked.\n  */\n \n-void Object::invokeMethod(BoundMethodBase *method, void *args)\n+void Object::invokeMethod(BoundMethodBase *method, InvocationType type, void *args)\n {\n \tstd::unique_ptr<Message> msg =\n \t\tutils::make_unique<InvokeMessage>(method, args, true);\ndiff --git a/src/libcamera/timer.cpp b/src/libcamera/timer.cpp\nindex ddb20954afa7..177fc24209ff 100644\n--- a/src/libcamera/timer.cpp\n+++ b/src/libcamera/timer.cpp\n@@ -170,7 +170,7 @@ 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, InvocationTypeAuto);\n \t\t}\n \t}\n \ndiff --git a/test/object-invoke.cpp b/test/object-invoke.cpp\nindex 37a274402e6d..6e0e24b146f0 100644\n--- a/test/object-invoke.cpp\n+++ b/test/object-invoke.cpp\n@@ -67,7 +67,7 @@ protected:\n \t\t * Test that method invocation in the same thread goes through\n \t\t * the event dispatcher.\n \t\t */\n-\t\tobject.invokeMethod(&InvokedObject::method, 42);\n+\t\tobject.invokeMethod(&InvokedObject::method, InvocationTypeAuto, 42);\n \n \t\tif (object.status() != InvokedObject::NoCall) {\n \t\t\tcerr << \"Method not invoked asynchronously\" << endl;\n@@ -101,7 +101,8 @@ protected:\n \n \t\tthread_.start();\n \n-\t\tobject.invokeMethod(&InvokedObject::method, 42);\n+\t\tobject.invokeMethod(&InvokedObject::method,\n+\t\t\t\t    InvocationTypeAuto, 42);\n \t\tthis_thread::sleep_for(chrono::milliseconds(100));\n \n \t\tswitch (object.status()) {\n","prefixes":["libcamera-devel","2/6"]}