summaryrefslogtreecommitdiff
path: root/src/libcamera/include/message.h
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-08-12 02:44:32 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-08-17 18:32:29 +0300
commitd5d7b71521cb9ad72505d66346227688134b8576 (patch)
tree980ba41623cc3a61073125aa854b806106238f4f /src/libcamera/include/message.h
parentf83820a5d18bfdfa9853ef3ef71abfb47f626ac8 (diff)
libcamera: object: Add an asynchronous method invocation method
Add a helper invokeMethod() to the Object class that allows asynchrnous invocation of any method of an Object instance. Asynchronous invocation occurs when control returns to the event dispatcher of the target object's thread, in the context of that thread. To support this, generalise the SignalMessage implementation to support automatic deletion of the associated BoundMethod, and rename the message to InvokeMessage to reflect the more generic purpose. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'src/libcamera/include/message.h')
-rw-r--r--src/libcamera/include/message.h17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/libcamera/include/message.h b/src/libcamera/include/message.h
index b4670c0e..92717e31 100644
--- a/src/libcamera/include/message.h
+++ b/src/libcamera/include/message.h
@@ -9,6 +9,8 @@
#include <atomic>
+#include <libcamera/bound_method.h>
+
namespace libcamera {
class BoundMethodBase;
@@ -20,7 +22,7 @@ class Message
public:
enum Type {
None = 0,
- SignalMessage = 1,
+ InvokeMessage = 1,
UserMessage = 1000,
};
@@ -41,16 +43,19 @@ private:
static std::atomic_uint nextUserType_;
};
-class SignalMessage : public Message
+class InvokeMessage : public Message
{
public:
- SignalMessage(BoundMethodBase *method, void *pack)
- : Message(Message::SignalMessage), method_(method), pack_(pack)
- {
- }
+ InvokeMessage(BoundMethodBase *method, void *pack,
+ bool deleteMethod = false);
+ ~InvokeMessage();
+
+ void invoke();
+private:
BoundMethodBase *method_;
void *pack_;
+ bool deleteMethod_;
};
} /* namespace libcamera */