libcamera: timer: Bind timers to threads

The Timer instances are registered with the event dispatcher instance of
the CameraManager. This makes it impossible to use timers in other
threads.

Fix this by inheriting from Object, which allows binding instances to a
thread, and register them with the event dispatcher for the thread they
are bound to.

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>
This commit is contained in:
Laurent Pinchart
2019-08-11 15:42:18 +03:00
parent 0c3fd6eb14
commit 6ecf99a708
2 changed files with 36 additions and 3 deletions
+10 -1
View File
@@ -9,11 +9,14 @@
#include <cstdint>
#include <libcamera/object.h>
#include <libcamera/signal.h>
namespace libcamera {
class Timer
class Message;
class Timer : public Object
{
public:
Timer();
@@ -28,7 +31,13 @@ public:
Signal<Timer *> timeout;
protected:
void message(Message *msg) override;
private:
void registerTimer();
void unregisterTimer();
unsigned int interval_;
uint64_t deadline_;
};