/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * Copyright (C) 2019, Google Inc. * * event_dispatcher_poll.h - Poll-based event dispatcher */ #ifndef __LIBCAMERA_BASE_EVENT_DISPATCHER_POLL_H__ #define __LIBCAMERA_BASE_EVENT_DISPATCHER_POLL_H__ #include #include #include #include #include struct pollfd; namespace libcamera { class EventNotifier; class Timer; class EventDispatcherPoll final : public EventDispatcher { public: EventDispatcherPoll(); ~EventDispatcherPoll(); void registerEventNotifier(EventNotifier *notifier); void unregisterEventNotifier(EventNotifier *notifier); void registerTimer(Timer *timer); void unregisterTimer(Timer *timer); void processEvents(); void interrupt(); private: struct EventNotifierSetPoll { short events() const; EventNotifier *notifiers[3]; }; int poll(std::vector *pollfds); void processInterrupt(const struct pollfd &pfd); void processNotifiers(const std::vector &pollfds); void processTimers(); std::map notifiers_; std::list timers_; int eventfd_; bool processingEvents_; }; } /* namespace libcamera */ #endif /* __LIBCAMERA_BASE_EVENT_DISPATCHER_POLL_H__ */