libqi-api  2.4.3.28
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Namespaces | Macros
strand.hpp File Reference
#include <qi/detail/executioncontext.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
#include <boost/noncopyable.hpp>
#include <boost/type_traits/function_traits.hpp>

Go to the source code of this file.

Classes

class  qi::Strand
 

Namespaces

 qi
 

Macros

#define _QI_STRAND_HPP_
 
#define genCall(n, ATYPEDECL, ATYPES, ADECL, AUSE, comma)
 
#define typedefi(z, n, _)
 
#define placeholders(z, n, __)   , BOOST_PP_CAT(_, BOOST_PP_INC(n))
 
#define genCall(n, ATYPEDECL, ATYPES, ADECL, AUSE, comma)
 

Macro Definition Documentation

#define _QI_STRAND_HPP_

Definition at line 8 of file strand.hpp.

#define genCall (   n,
  ATYPEDECL,
  ATYPES,
  ADECL,
  AUSE,
  comma 
)
Value:
template <typename T, typename F, typename ARG0 comma ATYPEDECL> \
boost::function<T> schedulerFor( \
const F& func, const ARG0& arg0 comma ADECL, \
const boost::function<void()>& fallbackCb = boost::function<void()>()) \
{ \
boost::function<T> funcbind = qi::bind<T>(func, arg0 comma AUSE); \
fallbackCb, \
SchedulerHelper<boost::function_traits<T>::arity, T>::_scheduler( \
funcbind, this), \
arg0); \
}
boost::function< F > trackWithFallback(boost::function< void()> onFail, const boost::function< F > &f, const ARG0 &arg0)
Wrap given function f with a tracking check on arg0, which must be a weak pointer or a Trackable inst...
Definition: trackable.hxx:212

Definition at line 78 of file strand.hpp.

#define genCall (   n,
  ATYPEDECL,
  ATYPES,
  ADECL,
  AUSE,
  comma 
)
Value:
template <typename T> \
struct SchedulerHelper<n, T> \
{ \
BOOST_PP_REPEAT(n, typedefi, _); \
typedef typename boost::function_traits<T>::result_type R; \
static boost::function<T> _scheduler(const boost::function<T>& f, \
Strand* strand) \
{ \
return qi::bind<T>(&_asyncCall, strand, \
f BOOST_PP_REPEAT(n, placeholders, _)); \
} \
static qi::Future<R> _asyncCall(Strand* strand, \
const boost::function<T>& func comma \
ADECL) \
{ \
/* use qi::bind again since first arg may be a Trackable */ \
return ((qi::ExecutionContext*)strand) \
->async(qi::bind<R()>(func comma AUSE)); \
} \
};
#define typedefi(z, n, _)
Definition: strand.hpp:74
boost::function< RF > bind(const AF &fun,...)
#define placeholders(z, n, __)
Definition: strand.hpp:77

Definition at line 78 of file strand.hpp.

#define placeholders (   z,
  n,
  __ 
)    , BOOST_PP_CAT(_, BOOST_PP_INC(n))

Definition at line 77 of file strand.hpp.

#define typedefi (   z,
  n,
  _ 
)
Value:
typedef typename boost::function_traits<T>::BOOST_PP_CAT( \
BOOST_PP_CAT(arg, BOOST_PP_INC(n)), _type) BOOST_PP_CAT(P, n);

Definition at line 74 of file strand.hpp.