blob: 1f7e05cfa037f1fd12602fe9071302145c25eba9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* Poll-based event dispatcher
*/
#pragma once
#include <list>
#include <map>
#include <vector>
#include <libcamera/base/private.h>
#include <libcamera/base/event_dispatcher.h>
#include <libcamera/base/unique_fd.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_;
UniqueFD eventfd_;
bool processingEvents_;
};
} /* namespace libcamera */
|