7 #ifndef _QI_EXECUTION_CONTEXT_HPP_
8 #define _QI_EXECUTION_CONTEXT_HPP_
10 #include <boost/function.hpp>
13 #include <type_traits>
31 typename std::enable_if<!std::is_same<
typename std::decay<Arg>::type,
Function>::value>::type* =
nullptr)
32 : boost::function<T>(std::forward<Arg>(arg))
59 typename boost::disable_if<std::is_same<R, void>,
qi::Future<R> >::type
65 typename boost::disable_if<std::is_same<R, void>,
qi::Future<R> >::type
79 void post(F&& callback);
94 virtual bool isInThisContext() = 0;
97 virtual void postImpl(boost::function<
void()> callback) = 0;
112 template <
typename T>
122 template <
typename R>
135 template <
typename R>
142 catch (
const std::exception& e)
151 template <
typename R>
161 template <
typename R>
162 typename boost::disable_if<std::is_same<R, void>,
169 detail::callAndSet<R>, promise, callback)),
178 template <
typename R>
179 typename boost::disable_if<std::is_same<R, void>,
186 detail::callAndSet<R>, promise, callback)),
195 template <
typename F>
198 postImpl(std::forward<F>(callback));
201 template <
typename ReturnType,
typename Callback>
213 detail::callAndSet<ReturnType>(std::move(
promise), std::move(
callback));
217 template <
typename F>
220 using ReturnType =
typename std::decay<decltype(callback())>::type;
225 promise.setup(
boost::bind(&detail::futureCancelAdapter<void>,
228 return promise.future();
231 template <
typename F>
234 using ReturnType =
typename std::decay<decltype(callback())>::type;
239 promise.setup(
boost::bind(&detail::futureCancelAdapter<void>,
242 return promise.future();
void setValue(qi::Promise< R > &p, const boost::function< R()> &f)
void setup(boost::function< void(qi::Promise< T >)> cancelCallback, FutureCallbackType async=FutureCallbackType_Async)
detail::DelayedPromise< ReturnType > promise
auto asyncDelay(F &&callback, qi::Duration delay) -> decltype(detail::asyncMaybeActor(std::forward< F >(callback), delay))
void setValue< void >(qi::Promise< void > &p, const boost::function< void()> &f)
void setup(boost::function< void(qi::Promise< T > &)> cancelCallback, FutureCallbackType async=FutureCallbackType_Auto)
void connect(const AF &fun, FutureCallbackType type=FutureCallbackType_Auto)
The future has been canceled.
virtual void postImpl(boost::function< void()> callback)=0
SteadyClock::time_point SteadyClockTimePoint
Steady clock time point.
virtual qi::Future< void > async(const boost::function< void()> &callback, qi::SteadyClockTimePoint tp)=0
void setError(const std::string &msg)
Function(Arg &&arg, typename std::enable_if<!std::is_same< typename std::decay< Arg >::type, Function >::value >::type *=nullptr)
dll import/export and compiler message
auto asyncDelay(F &&callback, qi::Duration delay) -> qi::Future< typename std::decay< decltype(callback())>::type >
call a callback asynchronously to be executed in delay
void callAndSet(qi::Promise< R > p, boost::function< R()> f)
typename detail::FunctionImpl< A >::type Function
Future< T > future() const
Get a future linked to this promise. Can be called multiple times.
Future< R > async(boost::function< R()> callback, uint64_t usDelay)
void post(F &&callback)
post a callback to be executed as soon as possible
#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)))
auto asyncAt(F &&callback, qi::SteadyClockTimePoint timepoint) -> decltype(qi::getEventLoop() ->asyncAt(std::forward< F >(callback), timepoint))
FutureState wait(int msecs=FutureTimeout_Infinite) const
auto asyncAt(F &&callback, qi::SteadyClockTimePoint tp) -> qi::Future< typename std::decay< decltype(callback())>::type >
call a callback asynchronously to be executed on tp
void checkCanceled(qi::Future< void > f, qi::Promise< R > p)
void setValue(const ValueType &value)
virtual ~ExecutionContext()
boost::shared_ptr< detail::FutureBaseTyped< T > > impl()
std::enable_if< std::is_function< RF >::value, boost::function< RF > >::type bind(AF &&fun, Arg0 &&arg0, Args &&...args)