7 #ifndef _QI_EXECUTION_CONTEXT_HPP_
8 #define _QI_EXECUTION_CONTEXT_HPP_
10 #include <type_traits>
11 #include <boost/function.hpp>
14 #include <ka/typetraits.hpp>
32 typename std::enable_if<!std::is_same<
typename std::decay<Arg>::type,
Function>::value>::type* =
nullptr)
33 : boost::function<T>(std::forward<Arg>(arg))
82 typename boost::disable_if<std::is_same<R, void>,
qi::Future<R> >::type
88 typename boost::disable_if<std::is_same<R, void>,
qi::Future<R> >::type
101 template <
typename F>
105 template <
typename F,
typename R = ka::Decay<decltype(std::declval<F>()())>>
108 template <
typename F,
typename R = ka::Decay<decltype(std::declval<F>()())>>
111 template <
typename F>
119 virtual bool isInThisContext()
const = 0;
122 virtual void postImpl(boost::function<
void()> callback,
ExecutionOptions options) = 0;
137 template <
typename T>
147 template <
typename R>
160 template <
typename R>
167 catch (
const std::exception& e)
176 template <
typename R>
191 template <
typename R>
192 typename boost::disable_if<std::is_same<R, void>,
199 detail::callAndSet<R>, promise, callback)),
208 template <
typename R>
209 typename boost::disable_if<std::is_same<R, void>,
216 detail::callAndSet<R>, promise, callback)),
225 template <
typename F>
228 postImpl(std::forward<F>(callback), options);
231 template <
typename ReturnType,
typename Callback>
243 detail::callAndSet<ReturnType>(std::move(
promise), std::move(
callback));
247 template <
typename F,
typename R>
253 promise.setup(
boost::bind(&detail::futureCancelAdapter<void>,
256 return promise.future();
259 template <
typename F,
typename R>
265 promise.setup(
boost::bind(&detail::futureCancelAdapter<void>,
268 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)
BOOST_CONSTEXPR ExecutionOptions defaultExecutionOptions() BOOST_NOEXCEPT
The future has been canceled.
... the execution context must not execute the task.
SteadyClock::time_point SteadyClockTimePoint
Steady clock time point.
CancelOption onCancelRequested
virtual qi::Future< void > asyncAtImpl(boost::function< void()> cb, qi::SteadyClockTimePoint tp, ExecutionOptions options)=0
virtual qi::Future< void > async(const boost::function< void()> &callback, qi::SteadyClockTimePoint tp)=0
void setError(const std::string &msg)
virtual void postImpl(boost::function< void()> callback, ExecutionOptions options)=0
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
... the executino context must still execute the task.
qi::Future< R > asyncDelay(F &&callback, qi::Duration delay, ExecutionOptions options=defaultExecutionOptions())
call a callback asynchronously to be executed in delay
void forwardError(qi::Future< void > f, qi::Promise< R > p)
void callAndSet(qi::Promise< R > p, boost::function< R()> f)
virtual qi::Future< void > asyncDelayImpl(boost::function< void()> cb, qi::Duration delay, ExecutionOptions options)=0
Future< T > future() const
Get a future linked to this promise. Can be called multiple times.
CancelOption
< If cancel have been requested for the associated scheduled task...
... allow the execution context to not execute the task.
Future is not tied to a promise.
auto async(F &&callback, ExecutionOptions options=defaultExecutionOptions()) -> decltype(asyncDelay(std::forward< F >(callback), qi::Duration(0), options))
#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))
The operation is finished with an error.
qi::Future< R > asyncAt(F &&callback, qi::SteadyClockTimePoint tp, ExecutionOptions options=defaultExecutionOptions())
call a callback asynchronously to be executed on tp
void post(F &&callback, ExecutionOptions options=defaultExecutionOptions())
post a callback to be executed as soon as possible
FutureState wait(int msecs=FutureTimeout_Infinite) const
const std::string & error(int msecs=FutureTimeout_Infinite) const
void setValue(const ValueType &value)
virtual ~ExecutionContext()
boost::shared_ptr< detail::FutureBaseTyped< T > > impl()
An accessor to the shared state. TODO: remove it, it should not exist.
The operation is finished with a value.
std::enable_if< std::is_function< RF >::value, boost::function< RF > >::type bind(AF &&fun, Arg0 &&arg0, Args &&...args)
Represent execution behaviour options attached to a task that must be interpreted by an ExecutionCont...