@@ -37,13 +37,13 @@ public:
void postMessage(std::unique_ptr<Message> msg);
template<typename T, typename... Args, typename std::enable_if<std::is_base_of<Object, T>::value>::type * = nullptr>
- void invokeMethod(void (T::*func)(Args...), Args... args)
+ void invokeMethod(void (T::*func)(Args...), InvocationType type, Args... args)
{
T *obj = static_cast<T *>(this);
BoundMethodBase *method = new BoundMemberMethod<T, Args...>(obj, this, func);
void *pack = new typename BoundMemberMethod<T, Args...>::PackType{ args... };
- invokeMethod(method, pack);
+ invokeMethod(method, type, pack);
}
Thread *thread() const { return thread_; }
@@ -60,7 +60,7 @@ private:
friend class BoundMethodBase;
friend class Thread;
- void invokeMethod(BoundMethodBase *method, void *pack);
+ void invokeMethod(BoundMethodBase *method, InvocationType type, void *pack);
void notifyThreadMove();
@@ -187,6 +187,7 @@ int CameraProxy::processCaptureRequest(camera3_capture_request_t *request)
void CameraProxy::threadRpcCall(ThreadRpc &rpcRequest)
{
- cameraDevice_->invokeMethod(&CameraDevice::call, &rpcRequest);
+ cameraDevice_->invokeMethod(&CameraDevice::call, InvocationTypeQueued,
+ &rpcRequest);
rpcRequest.waitDelivery();
}
@@ -128,7 +128,8 @@ void EventNotifier::message(Message *msg)
if (msg->type() == Message::ThreadMoveMessage) {
if (enabled_) {
setEnabled(false);
- invokeMethod(&EventNotifier::setEnabled, true);
+ invokeMethod(&EventNotifier::setEnabled,
+ InvocationTypeAuto, true);
}
}
@@ -160,9 +160,10 @@ void Object::message(Message *msg)
}
/**
- * \fn void Object::invokeMethod(void (T::*func)(Args...), Args... args)
+ * \fn void Object::invokeMethod(void (T::*func)(Args...), InvocationType type, Args... args)
* \brief Invoke a method asynchronously on an Object instance
* \param[in] func The object method to invoke
+ * \param[in] type The method invocation type
* \param[in] args The method arguments
*
* This method invokes the member method \a func when control returns to the
@@ -174,7 +175,7 @@ void Object::message(Message *msg)
* remains valid until the method is invoked.
*/
-void Object::invokeMethod(BoundMethodBase *method, void *args)
+void Object::invokeMethod(BoundMethodBase *method, InvocationType type, void *args)
{
std::unique_ptr<Message> msg =
utils::make_unique<InvokeMessage>(method, args, true);
@@ -170,7 +170,7 @@ void Timer::message(Message *msg)
if (msg->type() == Message::ThreadMoveMessage) {
if (isRunning()) {
unregisterTimer();
- invokeMethod(&Timer::registerTimer);
+ invokeMethod(&Timer::registerTimer, InvocationTypeAuto);
}
}
@@ -67,7 +67,7 @@ protected:
* Test that method invocation in the same thread goes through
* the event dispatcher.
*/
- object.invokeMethod(&InvokedObject::method, 42);
+ object.invokeMethod(&InvokedObject::method, InvocationTypeAuto, 42);
if (object.status() != InvokedObject::NoCall) {
cerr << "Method not invoked asynchronously" << endl;
@@ -101,7 +101,8 @@ protected:
thread_.start();
- object.invokeMethod(&InvokedObject::method, 42);
+ object.invokeMethod(&InvokedObject::method,
+ InvocationTypeAuto, 42);
this_thread::sleep_for(chrono::milliseconds(100));
switch (object.status()) {
Add the method invocation type to Object::invokeMethod() operation. The additional type parameter will be used when delivering InvokeMessages and decide if the caller should block waiting for reception or the message or return immediately. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> --- include/libcamera/object.h | 6 +++--- src/android/camera_proxy.cpp | 3 ++- src/libcamera/event_notifier.cpp | 3 ++- src/libcamera/object.cpp | 5 +++-- src/libcamera/timer.cpp | 2 +- test/object-invoke.cpp | 5 +++-- 6 files changed, 14 insertions(+), 10 deletions(-)