libcamera
v0.7.2
Supporting cameras in Linux since 2019
Toggle main menu visibility
Loading...
Searching...
No Matches
event_dispatcher_poll.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2
/*
3
* Copyright (C) 2019, Google Inc.
4
*
5
* Poll-based event dispatcher
6
*/
7
8
#pragma once
9
10
#include <list>
11
#include <map>
12
#include <vector>
13
14
#include <libcamera/base/private.h>
15
16
#include <
libcamera/base/event_dispatcher.h
>
17
#include <
libcamera/base/unique_fd.h
>
18
19
struct
pollfd;
20
21
namespace
libcamera
{
22
23
class
EventNotifier
;
24
class
Timer
;
25
26
class
EventDispatcherPoll final :
public
EventDispatcher
27
{
28
public
:
29
EventDispatcherPoll();
30
~EventDispatcherPoll();
31
32
void
registerEventNotifier
(
EventNotifier
*notifier);
33
void
unregisterEventNotifier
(
EventNotifier
*notifier);
34
35
void
registerTimer
(
Timer
*timer);
36
void
unregisterTimer
(
Timer
*timer);
37
38
void
processEvents
();
39
void
interrupt
();
40
41
private
:
42
struct
EventNotifierSetPoll {
43
short
events()
const
;
44
EventNotifier
*notifiers[3];
45
};
46
47
int
poll(std::vector<struct pollfd> *pollfds);
48
void
processInterrupt(
const
struct
pollfd &pfd);
49
void
processNotifiers(
const
std::vector<struct pollfd> &pollfds);
50
void
processTimers();
51
52
std::map<int, EventNotifierSetPoll> notifiers_;
53
std::list<Timer *> timers_;
54
UniqueFD
eventfd_;
55
56
bool
processingEvents_;
57
};
58
59
}
/* namespace libcamera */
libcamera::EventDispatcherPoll::registerTimer
void registerTimer(Timer *timer)
Register a timer.
Definition
event_dispatcher_poll.cpp:113
libcamera::EventDispatcherPoll::unregisterEventNotifier
void unregisterEventNotifier(EventNotifier *notifier)
Unregister an event notifier.
Definition
event_dispatcher_poll.cpp:80
libcamera::EventDispatcherPoll::unregisterTimer
void unregisterTimer(Timer *timer)
Unregister a timer.
Definition
event_dispatcher_poll.cpp:125
libcamera::EventDispatcherPoll::interrupt
void interrupt()
Interrupt any running processEvents() call as soon as possible.
Definition
event_dispatcher_poll.cpp:174
libcamera::EventDispatcherPoll::registerEventNotifier
void registerEventNotifier(EventNotifier *notifier)
Register an event notifier.
Definition
event_dispatcher_poll.cpp:65
libcamera::EventDispatcherPoll::processEvents
void processEvents()
Wait for and process pending events.
Definition
event_dispatcher_poll.cpp:142
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:20
libcamera::Timer
Single-shot timer interface.
Definition
timer.h:22
libcamera::UniqueFD
unique_ptr-like wrapper for a file descriptor
Definition
unique_fd.h:17
event_dispatcher.h
libcamera
Top-level libcamera namespace.
Definition
backtrace.h:17
unique_fd.h
File descriptor wrapper that owns a file descriptor.
include
libcamera
base
event_dispatcher_poll.h
Generated by
1.18.0