Webmaster  |  Imprint 
Platinum
Platinum C++ Framework
Main  |  License  |  Documentation  |  Download  |  Support 

EventLoop Class Reference

Thread-safe event loop supporting I/O multiplexing and Timers. More...

#include <Pt/System/EventLoop.h>

Inheritance diagram for EventLoop:

EventLoopBase SelectorBase Connectable NonCopyable

List of all members.

Public Member Functions

 EventLoop ()
 Constructs the EventLoop.
virtual ~EventLoop ()
 Destructs the EventLoop.

Protected Member Functions

virtual void onAdd (Selectable &s)
virtual void onRemove (Selectable &s)
virtual void onChanged (Selectable &s)
virtual void onRun ()
virtual bool onWait (std::size_t msecs)
virtual void onWake ()
virtual void onExit ()
virtual void onCommitEvent (const Event &event)
virtual void onProcessEvents ()


Detailed Description

The System EventLoop can be used as the central entity of a thread or process to dispatch application events and wait on multiple IODevices or Timers for activity.

Events can be added to the internal event queue, even from other threads using the method EventLoop::commitEvent or EventLoop::queueEvent. The first method will add the event to the internal queue and wake the event loop, the latter allows queing multiple event and it is up to the caller to wake the event loop by calling EventLoop::wake when all events are added. When the event loop processes its event, the signal "event" is send for each processed event. Events are processes in the order they were added.

To start the EventLoop the method EventLoop::run must be executed. It block until the event loop is stopped. To stop the EventLoop, EventLoop::exit must be called. The delivery of the events occurs inside the Thread that started the execution of the event loop.

IODevices and Timers can be added to an EventLoop just as to Selector. In fact a Selector is used internally to implement the EventLoop.

Since the EventLoop is a Runnable, it can be easily assigned to a Thread to give it its own event loop.

Copyright © 2003-2007 The Pt Development Team
Pt 1.0