7 #ifndef _QI_EVENTLOOP_HPP_
8 # define _QI_EVENTLOOP_HPP_
11 # pragma warning( disable: 4503 ) // decorated name length
14 # include <boost/thread/synchronized_value.hpp>
15 # include <boost/function.hpp>
23 # pragma warning( push )
24 # pragma warning( disable: 4251 )
25 # pragma warning( disable: 4996 ) // TODO: Reactivate this warning once msvc stop triggerring a warning on overloading a deprecated function
30 template<
typename T>
class Future;
32 class EventLoopPrivate;
49 explicit EventLoop(std::string
name =
"eventloop",
int nthreads = 0,
bool spawnOnOverload =
true);
59 EventLoop(std::string
name,
int nthreads,
int minThreads,
int maxThreads,
60 bool spawnOnOverload);
70 bool isInThisContext()
const override;
78 void start(
int threadCount = 0);
97 void setEmergencyCallback(boost::function<
void()> cb);
105 void setMinThreads(
unsigned int min);
112 void setMaxThreads(
unsigned int max);
115 void *nativeHandle();
137 return asyncDelayImpl(callback, delay);
143 return asyncAt(callback, timepoint);
155 void post(const boost::function<
void ()>& callback,
uint64_t usDelay)
160 void post(const boost::function<
void ()>& callback, qi::
Duration delay)
162 postDelayImpl(callback, delay);
181 using ImplPtr = std::shared_ptr<EventLoopPrivate>;
182 boost::synchronized_value<ImplPtr> _p;
185 void postImpl(boost::function<
void()> callback,
ExecutionOptions options)
override
190 void postDelayImpl(boost::function<
void()> callback,
qi::Duration delay
224 const char*
what() const KA_NOEXCEPT(true)
override
233 # pragma warning( pop )
239 #endif // _QI_EVENTLOOP_HPP_
DurationType< int64_t, boost::micro > MicroSeconds
BOOST_CONSTEXPR ExecutionOptions defaultExecutionOptions() BOOST_NOEXCEPT
SteadyClock::time_point SteadyClockTimePoint
Steady clock time point.
Class to handle eventloop. <includename>qi/eventloop.hpp</includename> .
virtual qi::Future< void > async(const boost::function< void()> &callback, qi::SteadyClockTimePoint tp)=0
dll import/export and compiler message
const char * what() const KA_NOEXCEPT(true) override
void startEventLoop(int nthread)
Starts the eventloop with nthread threads. Does nothing if already started.
#define QI_API_DEPRECATED_MSG(msg__)
Compiler flags to mark a function as deprecated. It will generate a compiler warning.
auto async(F &&callback) -> decltype(asyncDelay(std::forward< F >(callback), qi::Duration(0)))
EventLoop * getNetworkEventLoop()
Returns the global network eventloop, created on demand on first call.
EventLoop * getEventLoop()
Returns the global eventloop, created on demand on first call.
auto asyncAt(F &&callback, qi::SteadyClockTimePoint timepoint) -> decltype(qi::getEventLoop() ->asyncAt(std::forward< F >(callback), timepoint))
void post(F &&callback, ExecutionOptions options=defaultExecutionOptions())
post a callback to be executed as soon as possible
static const char * message()
Represent execution behaviour options attached to a task that must be interpreted by an ExecutionCont...