Kea: isc::util::SelectEventHandler Class Reference

| Kea 3.2.0-git

isc::util::SelectEventHandler Class Reference

File descriptor event handler class handles events for registered file descriptors. More...

`#include <select_event_handler.h>`

Inheritance diagram for isc::util::SelectEventHandler:
[legend]

## Public Member Functions
| SelectEventHandler ()
| Constructor.
virtual | ~SelectEventHandler ()=default
| Destructor.
void | add (int fd)
| Add file descriptor to watch for events.
void | clear ()
| Clear registered file descriptors.
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.
Public Member Functions inherited from isc::util::FDEventHandler
| FDEventHandler (HandlerType type=TYPE_UNKNOWN)
| Constructor.
virtual | ~FDEventHandler ()=default
| Destructor.
HandlerType | type ()
| Return the event handler type.

## Additional Inherited Members
Public Types inherited from isc::util::FDEventHandler
enum | HandlerType : uint16_t { TYPE_UNKNOWN = 0 , TYPE_SELECT = 1 , TYPE_POLL = 2 }

## Detailed Description

File descriptor event handler class handles events for registered file descriptors.

This class uses the OS select syscall for event handling.

Definition at line 19 of file select_event_handler.h.

## Constructor & Destructor Documentation

## ◆ SelectEventHandler()

isc::util::SelectEventHandler::SelectEventHandler | ( |  | ) |

Constructor.

Definition at line 24 of file select_event_handler.cc.

References isc::util::FDEventHandler::FDEventHandler(), clear(), and isc::util::FDEventHandler::TYPE_SELECT.

Here is the call graph for this function:

## ◆ ~SelectEventHandler()

virtual isc::util::SelectEventHandler::~SelectEventHandler | ( |  | ) |
| virtualdefault

Destructor.

## Member Function Documentation

## ◆ add()

void isc::util::SelectEventHandler::add | ( | int | fd | ) |
| virtual

Add file descriptor to watch for events.

Parameters

  fd | The file descriptor.

Implements isc::util::FDEventHandler.

Definition at line 30 of file select_event_handler.cc.

References isc_throw.

## ◆ clear()

void isc::util::SelectEventHandler::clear | ( |  | ) |
| virtual

Clear registered file descriptors.

Implements isc::util::FDEventHandler.

Definition at line 84 of file select_event_handler.cc.

Referenced by SelectEventHandler().

## ◆ hasError()

bool isc::util::SelectEventHandler::hasError | ( | int | fd | ) |
| virtual

Check if file descriptor has error.

Parameters

  fd | The file descriptor.

Returns
  True if file descriptor has error.

Implements isc::util::FDEventHandler.

Definition at line 74 of file select_event_handler.cc.

References isc_throw.

## ◆ readReady()

bool isc::util::SelectEventHandler::readReady | ( | int | fd | ) |
| virtual

Check if file descriptor is ready for read operation.

Parameters

  fd | The file descriptor.

Returns
  True if file descriptor is ready for reading.

Implements isc::util::FDEventHandler.

Definition at line 64 of file select_event_handler.cc.

References isc_throw.

## ◆ waitEvent()

int isc::util::SelectEventHandler::waitEvent | ( | uint32_t | timeout_sec,
|  | uint32_t | timeout_usec = 0,
|  | bool | use_timeout = true )
| virtual

Wait for events on registered file descriptors.

Parameters

  timeout_sec | The wait timeout in seconds.
  timeout_usec | The wait timeout in micro seconds.
  use_timeout | Flag which indicates if function should wait with no timeout (wait forever).

Returns
  -1 on error, 0 if no data is available (timeout expired), 1 if data is ready.

Implements isc::util::FDEventHandler.

Definition at line 44 of file select_event_handler.cc.

References FD_COPY, and isc_throw.

The documentation for this class was generated from the following files:

- select_event_handler.h
- select_event_handler.cc