event_dispatcher_poll.h
Go to the documentation of this file.
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* event_dispatcher_poll.h - Poll-based event dispatcher
*/
#ifndef __LIBCAMERA_INTERNAL_EVENT_DISPATCHER_POLL_H__
#define __LIBCAMERA_INTERNAL_EVENT_DISPATCHER_POLL_H__
#include <list>
#include <map>
#include <vector>
#include <libcamera/event_dispatcher.h>
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<struct pollfd> *pollfds);
void processInterrupt(const struct pollfd &pfd);
void processNotifiers(const std::vector<struct pollfd> &pollfds);
void processTimers();
std::map<int, EventNotifierSetPoll> notifiers_;
std::list<Timer *> timers_;
int eventfd_;
bool processingEvents_;
};
} /* namespace libcamera */
#endif /* __LIBCAMERA_INTERNAL_EVENT_DISPATCHER_POLL_H__ */
libcamera::EventDispatcherPoll
A poll-based event dispatcher.
Definition: event_dispatcher_poll.h:24
libcamera::EventDispatcherPoll::registerTimer
void registerTimer(Timer *timer)
Register a timer.
Definition: event_dispatcher_poll.cpp:116
libcamera::EventDispatcherPoll::unregisterEventNotifier
void unregisterEventNotifier(EventNotifier *notifier)
Unregister an event notifier.
Definition: event_dispatcher_poll.cpp:83
libcamera::EventDispatcherPoll::unregisterTimer
void unregisterTimer(Timer *timer)
Unregister a timer.
Definition: event_dispatcher_poll.cpp:128
libcamera::EventDispatcherPoll::interrupt
void interrupt()
Interrupt any running processEvents() call as soon as possible.
Definition: event_dispatcher_poll.cpp:177
libcamera::EventDispatcherPoll::registerEventNotifier
void registerEventNotifier(EventNotifier *notifier)
Register an event notifier.
Definition: event_dispatcher_poll.cpp:68
libcamera::EventDispatcherPoll::processEvents
void processEvents()
Wait for and process pending events.
Definition: event_dispatcher_poll.cpp:145
libcamera::EventDispatcher
Interface to manage the libcamera events and timers.
Definition: event_dispatcher.h:18
libcamera::EventNotifier
Notify of activity on a file descriptor.
Definition: event_notifier.h:18
libcamera::Timer
Single-shot timer interface.
Definition: timer.h:21
event_dispatcher.h