Kea: fd_event_handler.h Source File

| Kea 3.2.0-git

fd_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 FD_EVENT_HANDLER_H
8#define FD_EVENT_HANDLER_H
9
10#include <boost/shared_ptr.hpp>
11#include <stdint.h>
12
13namespace isc {
14namespace util {
15
18 class FDEventHandler {
19public:
20 enum HandlerType : uint16_t {
21 TYPE_UNKNOWN = 0,
22 TYPE_SELECT = 1,
23 TYPE_POLL = 2,
24 };
25
29 FDEventHandler(HandlerType type = TYPE_UNKNOWN);
30
32 virtual ~FDEventHandler() = default;
33
37 virtual void add(int fd) = 0;
38
47 virtual int waitEvent(uint32_t timeout_sec, uint32_t timeout_usec = 0,
48 bool use_timeout = true) = 0;
49
55 virtual bool readReady(int fd) = 0;
56
62 virtual bool hasError(int fd) = 0;
63
65 virtual void clear() = 0;
66
68 HandlerType type();
69
70private:
72 HandlerType type_;
73};
74
76 typedef boost::shared_ptr<FDEventHandler> FDEventHandlerPtr;
77
78} // namespace isc::util
79} // namespace isc
80
81#endif // FD_EVENT_HANDLER_H
isc::util::FDEventHandler::~FDEventHandler
virtual ~FDEventHandler()=default
Destructor.
isc::util::FDEventHandler::add
virtual void add(int fd)=0
Add file descriptor to watch for events.
isc::util::FDEventHandler::HandlerType
HandlerType
Definition fd_event_handler.h:20
isc::util::FDEventHandler::TYPE_POLL
@ TYPE_POLL
Definition fd_event_handler.h:23
isc::util::FDEventHandler::TYPE_UNKNOWN
@ TYPE_UNKNOWN
Definition fd_event_handler.h:21
isc::util::FDEventHandler::TYPE_SELECT
@ TYPE_SELECT
Definition fd_event_handler.h:22
isc::util::FDEventHandler::waitEvent
virtual int waitEvent(uint32_t timeout_sec, uint32_t timeout_usec=0, bool use_timeout=true)=0
Wait for events on registered file descriptors.
isc::util::FDEventHandler::type
HandlerType type()
Return the event handler type.
Definition fd_event_handler.cc:17
isc::util::FDEventHandler::FDEventHandler
FDEventHandler(HandlerType type=TYPE_UNKNOWN)
Constructor.
Definition fd_event_handler.cc:14
isc::util::FDEventHandler::readReady
virtual bool readReady(int fd)=0
Check if file descriptor is ready for read operation.
isc::util::FDEventHandler::hasError
virtual bool hasError(int fd)=0
Check if file descriptor has error.
isc::util::FDEventHandler::clear
virtual void clear()=0
Clear registered file descriptors.
isc::util
Definition time_utils.cc:43
isc::util::FDEventHandlerPtr
boost::shared_ptr< FDEventHandler > FDEventHandlerPtr
Shared pointer to an FD event handler.
Definition fd_event_handler.h:76
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18