Class EventLoop.

Inherits Garbage

This class dispatches event notifications to a list of Connections.

An EventLoop maintains a list of participating Connection objects, and periodically informs them about any events (e.g., read/write, errors, timeouts) that occur. The loop continues until something calls stop().

EventLoop::EventLoop()

Creates a new EventLoop.

Reimplements Garbage::Garbage().

void EventLoop::addConnection( Connection * c )

Adds c to this EventLoop's list of active Connections.

If shutdown() has been called already, addConnection() ignores c, so that shutdown proceeds unhampered. This is likely to disturb c a little, but it's better than the alternative: Aborting the shutdown.

void EventLoop::addTimer( Timer * t )

Records that t exists, so that the event loop will process t.

void EventLoop::closeAllExcept( Connection * c1, Connection * c2 )

Closes all Connections except c1 and c2. This helps TlsProxy do its work.

void EventLoop::closeAllExceptListeners()

Closes all Connection except Listeners. When we fork, this allows us to keep the connections on one side of the fence.

List< Connection > * EventLoop::connections() const

Returns a (non-zero) pointer to the list of Connections that have been added to this EventLoop.

void EventLoop::dispatch( Connection * c, bool r, bool w, uint now )

Dispatches events to the connection c, based on its current state, the time now and the results from select: r is true if the FD may be read, and w is true if we know that the FD may be written to. If now is past that Connection's timeout, we must send a Timeout event.

void EventLoop::flushAll()

Flushes the write buffer of all connections.

static void EventLoop::freeMemorySoon()

Requests the event loop to collect garbage and clear any caches at the earliest opportunity. Used for debugging.

static EventLoop * EventLoop::global()

Returns a pointer to the global event loop, or 0 if setup() has not yet been called.

bool EventLoop::inShutdown() const

Returns true if this EventLoop is shutting down (ie. stop() has been called), and false if it's starting up or operating normally.

bool EventLoop::inStartup() const

Returns true if this EventLoop is still attending to startup chores, and not yet processing Listener requests.

uint EventLoop::memoryUsage() const

Returns whatever setMemoryUsage() has recorded, or 0 meaning to collect garbage often.

void EventLoop::removeConnection( Connection * c )

Removes c from this EventLoop's list of active Connections.

void EventLoop::removeTimer( Timer * t )

Forgets that t exists. The event loop will henceforth never call t.

void EventLoop::setConnectionCounts()

Scans the event loop and stores the current number of different connections using GraphableNumber.

void EventLoop::setMemoryUsage( uint limit )

Instructs this event loop to collect garbage when memory usage passes limit bytes. The default is 0, which means to collect garbage even if very little is being used.

void EventLoop::setStartup( bool p )

Sets the startup state of this EventLoop to p. If p is true, then Listeners will not be processed until this function is called again with p set to false.

static void EventLoop::setup( EventLoop * l )

Creates the global EventLoop object or, if l is non-zero, sets the global EventLoop to l. This function expects to be called very early during the startup sequence.

static void EventLoop::shutdown()

This static function is just a convenient shorthand for calling stop() on the global() EventLoop.

void EventLoop::shutdownSSL()

Stops all the SSL-enabled Listeners.

void EventLoop::start()

Starts the EventLoop and runs it until stop() is called.

void EventLoop::stop( uint s )

Instructs this EventLoop to perform an orderly shutdown in s seconds, by sending each participating Connection a Shutdown event before closing.

Listener connections are closed right away, some/all external connections get a Shutdown event at once, everyone get a Shutdown event at final shutdown.

EventLoop::~EventLoop()

Exists only to avoid compiler warnings.

This web page based on source code belonging to The Archiveopteryx Developers. All rights reserved.