27aff949fb
Move the functionality for the following components to the new base support library: - BoundMethod - EventDispatcher - EventDispatcherPoll - Log - Message - Object - Signal - Semaphore - Thread - Timer While it would be preferable to see these split to move one component per commit, these components are all interdependent upon each other, which leaves us with one big change performing the move for all of them. Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
59 lines
1.2 KiB
C++
59 lines
1.2 KiB
C++
/* 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 <list>
|
|
#include <map>
|
|
#include <vector>
|
|
|
|
#include <libcamera/base/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_BASE_EVENT_DISPATCHER_POLL_H__ */
|