COROIO: NNet::TLoop< TPoller > Class Template Reference
COROIO
 
Loading...
Searching...
No Matches
NNet::TLoop< TPoller > Class Template Reference

Event loop that drives a poller backend. More...

#include <loop.hpp>

Public Member Functions

void Loop ()
 Runs the main loop until Stop() is called.
 
void Stop ()
 Stops the loop.
 
void Step ()
 Runs one event-loop iteration: polls for I/O/timer events then resumes all coroutines whose events fired.
 
TPoller & Poller ()
 Provides access to the underlying poller instance.
 

Detailed Description

template<typename TPoller>
class NNet::TLoop< TPoller >

Event loop that drives a poller backend.

Each call to Step() runs one polling round: it calls Poller_.Poll() to collect ready I/O events and timers, then Poller_.WakeupReadyHandles() to resume the waiting coroutines.

Loop() repeats Step() until Stop() is called. For manual control (e.g. driving the loop until a specific TFuture completes), use Step() directly:

TFuture<void> task = my_coroutine(loop.Poller());
while (!task.done())
loop.Step();
Event loop that drives a poller backend.
Definition loop.hpp:30
TPoller & Poller()
Provides access to the underlying poller instance.
Definition loop.hpp:57
void Step()
Runs one event-loop iteration: polls for I/O/timer events then resumes all coroutines whose events fi...
Definition loop.hpp:50
Owned coroutine handle that carries a result of type T.
Definition corochain.hpp:185

For server-style programs with detached TVoidTask coroutines:

server(loop.Poller(), TAddress{"::", 8888}); // returns TVoidTask
loop.Loop(); // runs until Stop() is called
A class representing an IPv4 or IPv6 address (with port).
Definition address.hpp:38
void Loop()
Runs the main loop until Stop() is called.
Definition loop.hpp:35
Template Parameters
TPollerPolling backend: TEPoll, TKqueue, TIOCp, TUring, TPoll, TSelect, etc.

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