summaryrefslogtreecommitdiff
path: root/src/cam/event_loop.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/cam/event_loop.h')
-rw-r--r--src/cam/event_loop.h27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/cam/event_loop.h b/src/cam/event_loop.h
index 581c7cba..ba3ba3a4 100644
--- a/src/cam/event_loop.h
+++ b/src/cam/event_loop.h
@@ -7,28 +7,39 @@
#ifndef __CAM_EVENT_LOOP_H__
#define __CAM_EVENT_LOOP_H__
-#include <atomic>
+#include <functional>
+#include <list>
+#include <mutex>
-#include <libcamera/event_notifier.h>
+#include <event2/util.h>
-namespace libcamera {
-class EventDispatcher;
-}
+struct event_base;
class EventLoop
{
public:
- EventLoop(libcamera::EventDispatcher *dispatcher);
+ EventLoop();
~EventLoop();
+ static EventLoop *instance();
+
int exec();
void exit(int code = 0);
+ void callLater(const std::function<void()> &func);
+
private:
- libcamera::EventDispatcher *dispatcher_;
+ static EventLoop *instance_;
- std::atomic<bool> exit_;
+ struct event_base *base_;
int exitCode_;
+
+ std::list<std::function<void()>> calls_;
+ std::mutex lock_;
+
+ static void dispatchCallback(evutil_socket_t fd, short flags,
+ void *param);
+ void dispatchCall();
};
#endif /* __CAM_EVENT_LOOP_H__ */