Why: Eventloop (“Polling”)#

class Eventloop#

Concept that checks if a type has a _pollfd() method.

This concept is used to constrain template parameters to types that provide a kernel object for polling.

Event loop for monitoring kernel objects and invoking callbacks

The Eventloop class provides a mechanism to watch multiple kernel objects and execute callbacks when events occur on those objects.

Template Parameters:

KOBJ – The type to check

Public Functions

template<typename KOBJ>
inline void watch(KOBJ &obj, std::function<void()> callback)#

Register an object for monitoring.

Adds an object to the event loop’s watch list. When events occur on the object’s kernel object, the provided callback will be invoked.

Template Parameters:

KOBJ – Type of the object to watch (must satisfy has_pollfd concept)

Parameters:
  • obj – The object to monitor

  • callback – Function to call when events occur

inline void operator()()#

Run the event loop indefinitely.

Continuously processes events by repeatedly calling one(). This function does not return under normal circumstances.

void one()#

Process one iteration of the event loop.

Polls all watched kernel objects and invokes callbacks for any that have pending events.