Home

epolldatat

Epolldatat refers to the epoll_data_t union used in the Linux epoll I/O event notification API. It is the data field associated with epoll_event that allows a program to attach user-specific context to each monitored file descriptor.

The epoll_data_t union provides several ways to store the event’s associated information. It typically includes members

In practice, epoll_event structures carry an events mask and a data field of type epoll_data_t. When a

Common usage patterns favor storing a pointer to a per-connection structure in data.ptr, especially on 64-bit

See also: epoll, epoll_ctl, epoll_wait, epoll_event.

such
as
a
file
descriptor
(fd),
a
generic
pointer
(ptr),
and
integer
representations
(u32
and
u64).
The
exact
definition
is
exposed
in
the
system
headers
that
implement
epoll,
such
as
the
Linux
kernel
headers
and
the
C
library
headers,
and
is
designed
to
be
large
enough
to
hold
either
a
pointer
or
small
integers
depending
on
the
platform.
file
descriptor
is
added
to
the
epoll
instance
with
epoll_ctl,
the
programmer
fills
the
event’s
data
with
the
desired
context—often
a
pointer
to
a
per-connection
or
per-item
state,
or
an
integer
index.
When
epoll_wait
returns
one
or
more
ready
events,
the
corresponding
event
entries
expose
the
same
data
field,
allowing
the
program
to
recover
the
associated
context
and
interpret
it
according
to
how
it
was
stored.
systems,
while
data.fd
can
be
used
to
carry
a
file
descriptor
when
appropriate.
Developers
must
ensure
that
any
stored
pointers
remain
valid
for
the
lifetime
of
the
event
and
handle
safety
when
objects
are
destroyed.