7 #ifndef _QI_EVENTLOOP_HPP_
8 #define _QI_EVENTLOOP_HPP_
11 # pragma warning( disable: 4503 ) // decorated name length
14 #include <boost/shared_ptr.hpp>
15 #include <boost/function.hpp>
21 # pragma warning( push )
22 # pragma warning( disable: 4251 )
34 class EventLoopPrivate;
41 EventLoop(
const std::string& name =
"eventloop");
44 bool isInEventLoopThread();
46 void start(
int nthreads = 0);
48 void startThreadPool(
int minWorkers=-1,
int maxWorkers=-1,
int minIdleWorkers=-1,
int maxIdleWorkers=-1);
56 void setEmergencyCallback(boost::function<
void()> cb);
59 void setMaxThreads(
unsigned int max);
76 void post(
const boost::function<
void ()>& callback,
uint64_t usDelay=0);
111 class TerminateThread {
117 # pragma warning( pop )
121 #endif // _QI_EVENTLOOP_HPP_
boost::asio::io_service & getIoService()
Return the io_service used by the global event loop.
QI_API_DEPRECATED EventLoop * getDefaultNetworkEventLoop()
uint64_t uint64_t
Cross-platform unsigned integer of length 64 bits (8 bytes).
void startEventLoop(int nthread)
Start the eventloop with nthread threads. No-op if already started.
EventLoop * getEventLoop()
Return the global eventloop, created on demand on first call.
#define QI_API_DEPRECATED
Compiler flags to mark a function as deprecated. It will generate a compiler warning.
dll import/export and compiler message
QI_API_DEPRECATED EventLoop * getDefaultThreadPoolEventLoop()
Return a default thread pool context.
QI_API_DEPRECATED EventLoop * getDefaultObjectEventLoop()
Return a default context for other uses.