5 #ifndef _QI_PERIODICTASK_HPP_
6 # define _QI_PERIODICTASK_HPP_
10 # include <boost/function.hpp>
11 # include <boost/utility.hpp>
22 struct PeriodicTaskPrivate;
46 auto setCallback(T&& cb) ->
typename std::enable_if<detail::IsAsyncBind<typename std::decay<T>::type>::value>::type
48 static_assert(
sizeof(T) &&
false,
49 "Don't use PeriodicTask::setCallback(qi::bind(...)) but setCallback(...) directly");
52 auto setCallback(T&& cb) ->
typename std::enable_if<!detail::IsAsyncBind<typename std::decay<T>::type>::value>::type
54 _setCallback(std::forward<T>(cb));
56 template <
typename AF,
typename ARG0,
typename... ARGS>
57 inline void setCallback(AF&& callable, ARG0&& arg0, ARGS&&... args)
59 _connectMaybeActor(arg0);
60 _setCallback(
boost::bind(std::forward<AF>(callable), std::forward<ARG0>(arg0), std::forward<ARGS>(args)...));
94 void start(
bool immediate =
true);
122 void compensateCallbackTime(
bool compensate);
126 void setName(
const std::string&
name);
129 bool isRunning()
const;
137 bool isStopping()
const;
140 boost::shared_ptr<PeriodicTaskPrivate> _p;
142 template <
typename ARG0>
143 inline typename boost::enable_if<
144 boost::is_base_of<Actor, typename detail::Unwrap<ARG0>::type>,
146 _connectMaybeActor(
const ARG0& arg0)
150 template <
typename ARG0>
151 inline typename boost::disable_if<
152 boost::is_base_of<Actor, typename detail::Unwrap<ARG0>::type>,
154 _connectMaybeActor(
const ARG0& arg0)
159 void _setCallback(
const Callback& cb);
Control a task executed periodically and asynchronously. <includename>qi/periodictask.hpp</includename> .
void setCallback(AF &&callable, ARG0 &&arg0, ARGS &&...args)
auto setCallback(T &&cb) -> typename std::enable_if<!detail::IsAsyncBind< typename std::decay< T >::type >::value >::type
std::enable_if< std::is_function< RF >::value, boost::function< RF > >::type bind(AF &&fun, Arg0 &&arg0, Args &&...args)
auto setCallback(T &&cb) -> typename std::enable_if< detail::IsAsyncBind< typename std::decay< T >::type >::value >::type
boost::function< void()> Callback
Callback is a boost::function.