Why: Eventloop (“Polling”)#
-
class Eventloop#
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.
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.
-
template<typename KOBJ>