Simple event loop example. More...
#include <simpleeventloop.h>
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. | |
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.
| void TPProto::SimpleEventLoop::listenForSocketRead | ( | TPSocket * | sock | ) | [virtual] |
Adds a TPSocket to the reading list.
| 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.
| 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.
| interval | Time in seconds until the callback is called. | |
| callback | The callback to call when the timer expires. |
Implements TPProto::EventLoop.
References TPProto::Timer::expiretime, and TPProto::Timer::signal.
1.6.1