Module poll

Source
Expand description

§XDP Socket Poll Utilities

This file provides utilities for polling XDP socket file descriptors. It enables waiting for readiness events such as readability or writability, which is essential for efficient I/O in high-performance networking scenarios. The utilities abstract low-level polling mechanisms and can be used to integrate XDP sockets with event-driven or blocking code.

Since poll_wait is not a part of core API, you have to import PollWait trait to enable it.

§How it works

The poll_wait method blocks the current thread until the socket’s file descriptor becomes ready for I/O. It uses poll to wait for the socket’s readiness event, which depends on the socket direction:

  • For transmit sockets (_TX), it waits for the socket to be writable (POLLOUT).
  • For receive sockets (_RX), it waits for the socket to be readable (POLLIN).

§Main components

  • impl PollWait<_TX>: An implementation block for the transmit socket.
  • impl PollWait<_RX>: An implementation block for the receive socket.
  • poll_wait(): A method to block until a socket becomes ready for I/O.

Traits§

PollWaitExt
A trait for polling XDP sockets for readiness events.