TPProto::SimpleEventLoop Class Reference

Simple event loop example. More...

#include <simpleeventloop.h>

Inheritance diagram for TPProto::SimpleEventLoop:
TPProto::EventLoop

List of all members.

Public Member Functions

 SimpleEventLoop ()
 Constructs the SimpleEventLoop.
virtual ~SimpleEventLoop ()
 Desctructs the SimpleEventLoop. Frees the TPSockets that are still open.
virtual void listenForSocketRead (TPSocket *sock)
 Adds a TPSocket to the reading list.
virtual void listenForSocketWrite (TPSocket *sock)
 Adds a TPSocket to the writing list.
virtual TimerConnection setTimer (uint32_t interval, const TimerSignal::slot_type &callback)
 Set a timer to be called.
void runEventLoop ()
 Runs the EventLoop. Call to start processing event. This does not exit until after SimpleEventLoop::endEventLoop() is called.
void endEventLoop ()
 End the eventloop processing. Cause the call to SimpleEventLoop::runEventLoop() to exit the next time it loops.

Detailed Description

Simple event loop example.

This class is a subclass of EventLoop to demostrate how to interact with an existing event loop. The whole eventloop is implemented in this class.

This SimpleEventLoop is used by the tests and some example programs.


Member Function Documentation

void TPProto::SimpleEventLoop::listenForSocketRead ( TPSocket sock  )  [virtual]

Adds a TPSocket to the reading list.

Parameters:
sock The TPSocket that wants to read. The TPSocket remains in the list until closed or removed.

Implements TPProto::EventLoop.

void TPProto::SimpleEventLoop::listenForSocketWrite ( TPSocket sock  )  [virtual]

Adds a TPSocket to the writing list.

Parameters:
sock The TPSocket that wants to write. After it has written, it is removed from the writing list. To write more, the TPSocket has to be re-added to the writing list.

Implements TPProto::EventLoop.

TimerConnection TPProto::SimpleEventLoop::setTimer ( uint32_t  interval,
const TimerSignal::slot_type &  callback 
) [virtual]

Set a timer to be called.

Parameters:
interval Time in seconds until the callback is called.
callback The callback to call when the timer expires.
Returns:
The TimerConnection that can be used to manage the timer

Implements TPProto::EventLoop.

References TPProto::Timer::expiretime, and TPProto::Timer::signal.


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

Generated on Wed Mar 17 03:15:07 2010 for libtpproto-cpp by  doxygen 1.6.1