Kea 3.1.5
poll_event_handler.h
Go to the documentation of this file.
1// Copyright (C) 2025 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef POLL_EVENT_HANDLER_H
8#define POLL_EVENT_HANDLER_H
9
11
12#include <unordered_map>
13#include <unordered_set>
14#include <vector>
15
16#include <sys/poll.h>
17
18namespace isc {
19namespace util {
20
24public:
27
29 virtual ~PollEventHandler() = default;
30
34 void add(int fd);
35
44 int waitEvent(uint32_t timeout_sec, uint32_t timeout_usec = 0,
45 bool use_timeout = true);
46
52 bool readReady(int fd);
53
59 virtual bool hasError(int fd);
60
62 void clear();
63
64private:
66 std::vector<struct pollfd> data_;
67
69 std::unordered_map<int, struct pollfd*> map_;
70};
71
72} // namespace isc::util;
73} // namespace isc
74
75#endif // POLL_EVENT_HANDLER_H
FDEventHandler(HandlerType type=TYPE_UNKNOWN)
Constructor.
virtual ~PollEventHandler()=default
Destructor.
void add(int fd)
Add file descriptor to watch for events.
virtual bool hasError(int fd)
Check if file descriptor has error.
bool readReady(int fd)
Check if file descriptor is ready for read operation.
int waitEvent(uint32_t timeout_sec, uint32_t timeout_usec=0, bool use_timeout=true)
Wait for events on registered file descriptors.
void clear()
Clear registered file descriptors.
Defines the logger used by the top-level component of kea-lfc.