libqi-api  2.0.6.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Public Attributes
qi::EventLoop Class Reference

#include <eventloop.hpp>

List of all members.

Public Member Functions

 EventLoop ()
 ~EventLoop ()
bool isInEventLoopThread ()
 Return true if current thread is the event loop thread.
void start (int nthreads=0)
 Start in threaded mode.
void startThreadPool (int minWorkers=-1, int maxWorkers=-1, int minIdleWorkers=-1, int maxIdleWorkers=-1)
 Start in thread-pool mode: each asyncCall() will be run in parallel.
void join ()
 Wait for run thread to terminate.
void stop ()
 Ask main loop to terminate.
void run ()
 Run main loop in current thread.
void setEmergencyCallback (boost::function< void()> cb)
 Set callback to be called in case of a deadlock detection.
void setMaxThreads (unsigned int max)
 Set the maximum number of threads in the pool.
void * nativeHandle ()
void post (const boost::function< void()> &callback, uint64_t usDelay=0)
 Similar to async() but without cancelation or notification.
Future< void > monitorEventLoop (EventLoop *helper, uint64_t maxUsDelay)
template<typename R >
Future< R > async (boost::function< R()> callback, uint64_t usDelay=0)
Future< void > async (boost::function< void()> callback, uint64_t usDelay=0)

Public Attributes

EventLoopPrivate * _p

Detailed Description

Definition at line 35 of file eventloop.hpp.


Constructor & Destructor Documentation

Create a new eventLoop. You must then call either start(), run() or startThreadPool() to start event processing.


Member Function Documentation

template<typename R >
Future< R > qi::EventLoop::async ( boost::function< R()>  callback,
uint64_t  usDelay = 0 
)

Call given function once after given delay in microseconds.

Returns:
a canceleable future

Definition at line 51 of file eventloop.hxx.

Future<void> qi::EventLoop::async ( boost::function< void()>  callback,
uint64_t  usDelay = 0 
)

Return true if current thread is the event loop thread.

Wait for run thread to terminate.

Future<void> qi::EventLoop::monitorEventLoop ( EventLoop helper,
uint64_t  maxUsDelay 
)

Monitor event loop to detect deadlocks.

Parameters:
helperan other event loop used for monitoring
maxUsDelaymaximum expected delay between an async() and its execution
Returns:
a canceleable future. Invoke cancel() to terminate monitoring. In case an async() call does not execute in time, the future's error will be set.
void qi::EventLoop::post ( const boost::function< void()> &  callback,
uint64_t  usDelay = 0 
)

Similar to async() but without cancelation or notification.

Run main loop in current thread.

void qi::EventLoop::setEmergencyCallback ( boost::function< void()>  cb)

Set callback to be called in case of a deadlock detection.

void qi::EventLoop::setMaxThreads ( unsigned int  max)

Set the maximum number of threads in the pool.

void qi::EventLoop::start ( int  nthreads = 0)

Start in threaded mode.

void qi::EventLoop::startThreadPool ( int  minWorkers = -1,
int  maxWorkers = -1,
int  minIdleWorkers = -1,
int  maxIdleWorkers = -1 
)

Start in thread-pool mode: each asyncCall() will be run in parallel.

Ask main loop to terminate.


Member Data Documentation

EventLoopPrivate* qi::EventLoop::_p

Definition at line 87 of file eventloop.hpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines