Miosix  2.0alpha1
miosix::EventQueue Class Reference

#include <e20.h>

Public Member Functions

 EventQueue ()
 
void post (std::tr1::function< void()> event)
 
void run ()
 
void runOne ()
 
unsigned int size () const
 
bool empty () const
 

Detailed Description

A variable sized event queue.

Makes use of heap allocations and as such it is not possible to post events from within interrupt service routines. For this, use FixedEventQueue.

This class acts as a synchronization point, multiple threads can post events, and multiple threads can call run() or runOne() (thread pooling).

Events are function that are posted by a thread through post() but executed in the context of the thread that calls run() or runOne()

Constructor & Destructor Documentation

miosix::EventQueue::EventQueue ( )
inline

Constructor

Member Function Documentation

bool miosix::EventQueue::empty ( ) const
inline
Returns
true if the queue has no events
void miosix::EventQueue::post ( std::tr1::function< void()>  event)

Post an event to the queue. This function never blocks.

Parameters
eventfunction function to be called in the thread that calls run() or runOne(). Bind can be used to bind parameters to the function.
Exceptions
std::bad_allocif there is not enough heap memory
void miosix::EventQueue::run ( )

This function blocks waiting for events being posted, and when available it calls the event function. To return from this event loop an event function must throw an exception.

Exceptions
anyexception that is thrown by the event functions
void miosix::EventQueue::runOne ( )

Run at most one event. This function does not block.

Exceptions
anyexception that is thrown by the event functions
unsigned int miosix::EventQueue::size ( ) const
inline
Returns
the number of events in the queue

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