From 01b930964acdd9475d46044c459396f8c3cf8a79 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sun, 24 Mar 2019 03:21:28 +0200 Subject: libcamera: thread: Add a messaging passing API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Create a new Message class to model a message that can be passed to an object living in another thread. Only an invalid message type is currently defined, more messages will be added in the future. The Thread class is extended with a messages queue, and the Object class with thread affinity. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- include/libcamera/object.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include/libcamera/object.h') diff --git a/include/libcamera/object.h b/include/libcamera/object.h index eadd41f9..d61dfb1e 100644 --- a/include/libcamera/object.h +++ b/include/libcamera/object.h @@ -8,26 +8,39 @@ #define __LIBCAMERA_OBJECT_H__ #include +#include namespace libcamera { +class Message; class SignalBase; template class Signal; +class Thread; class Object { public: + Object(); virtual ~Object(); + void postMessage(std::unique_ptr msg); + virtual void message(Message *msg); + + Thread *thread() const { return thread_; } + void moveToThread(Thread *thread); + private: template friend class Signal; + friend class Thread; void connect(SignalBase *signal); void disconnect(SignalBase *signal); + Thread *thread_; std::list signals_; + unsigned int pendingMessages_; }; }; /* namespace libcamera */ -- cgit v1.2.1