#include <Pt/System/MainLoop.h>
Thread-safe event loop supporting I/O multiplexing and Timers. More...
Inherits EventLoop.
Public Member Functions | |
MainLoop () | |
Default Constructor. | |
MainLoop (Allocator &a) | |
Construct with allocator. | |
virtual | ~MainLoop () |
Destructor. | |
void | commitEvent (const Event &ev) |
Queues an event and triggers event processing. | |
Signal< const Event & > & | eventReceived () |
Reports all events. | |
void | exit () |
Stops the loop. | |
Signal & | exited () |
Emited when the eventloop is exited. | |
void | post (Selectable &s) |
Calls the selectables run function in the loop thread. More... | |
void | processEvents () |
Process all queued events. | |
void | queueEvent (const Event &ev) |
Only queues an event. | |
void | run () |
Starts the loop. | |
void | wake () |
Triggers event processing. | |
Protected Member Functions | |
virtual void | onCommitEvent (const Event &ev) |
Queues an event and triggers event processing. | |
virtual void | onQueueEvent (const Event &ev) |
Only queues an event. | |
virtual void | onWake () |
Triggers event processing. | |
The following example uses a MainLoop to wait on acitvity on a Timer, which is set to time-out after 1000 msecs.
|
inherited |
The event loop is woken up and the selectable's run function is called in the thread that called the event loop's run function. This function may be called from any thread, since it is meant to return to the event loop thread from a selectable, that is based on a parallel execution model e.g. using a worker thread.