libqi-api  release-2.5.3-2016-11-18
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | List of all members
qi::Strand Class Reference

#include <strand.hpp>

Public Member Functions

 Strand ()
 Construct a strand that will schedule work on the default event loop. More...
 
 Strand (qi::ExecutionContext &executionContext)
 Construct a strand that will schedule work on executionContext. More...
 
 ~Strand ()
 Call detroy() More...
 
void join ()
 
qi::Future< void > async (const boost::function< void()> &cb, qi::SteadyClockTimePoint tp) override
 
qi::Future< void > async (const boost::function< void()> &cb, qi::Duration delay) override
 
bool isInThisContext () override
 
template<typename F >
auto schedulerFor (F &&func, boost::function< void()> onFail={}) -> detail::WrapInStrand< typename std::decay< F >::type >
 
- Public Member Functions inherited from qi::ExecutionContext
virtual ~ExecutionContext ()
 
template<typename R >
boost::disable_if
< std::is_same< R, void >
, qi::Future< R > >::type 
async (const boost::function< R()> &callback, qi::Duration delay)
 
template<typename R >
boost::disable_if
< std::is_same< R, void >
, qi::Future< R > >::type 
async (const boost::function< R()> &callback, qi::SteadyClockTimePoint tp)
 
template<typename R >
qi::Future< R > async (const detail::Function< R()> &callback)
 
template<typename F >
void post (F &&callback)
 post a callback to be executed as soon as possible More...
 
template<typename F >
auto asyncAt (F &&callback, qi::SteadyClockTimePoint tp) -> qi::Future< typename std::decay< decltype(callback())>::type >
 call a callback asynchronously to be executed on tp More...
 
template<typename F >
auto asyncDelay (F &&callback, qi::Duration delay) -> qi::Future< typename std::decay< decltype(callback())>::type >
 call a callback asynchronously to be executed in delay More...
 
template<typename F >
auto async (F &&callback) -> decltype(asyncDelay(std::forward< F >(callback), qi::Duration(0)))
 

Additional Inherited Members

Detailed Description

Class that schedules tasks sequentially

A strand allows one to schedule work on an eventloop with the guaranty that two callback will never be called concurrently.

Methods are thread-safe except for destructor which must never be called concurrently.

Definition at line 101 of file strand.hpp.

Constructor & Destructor Documentation

qi::Strand::Strand ( )

Construct a strand that will schedule work on the default event loop.

qi::Strand::Strand ( qi::ExecutionContext executionContext)

Construct a strand that will schedule work on executionContext.

qi::Strand::~Strand ( )

Call detroy()

Member Function Documentation

qi::Future<void> qi::Strand::async ( const boost::function< void()> &  callback,
qi::SteadyClockTimePoint  tp 
)
overridevirtual

call a callback asynchronously to be executed on tp

Deprecated:
since 2.5

Implements qi::ExecutionContext.

qi::Future<void> qi::Strand::async ( const boost::function< void()> &  callback,
qi::Duration  delay 
)
overridevirtual

call a callback asynchronously to be executed in delay

Deprecated:
since 2.5

Implements qi::ExecutionContext.

bool qi::Strand::isInThisContext ( )
overridevirtual
Returns
true if current code is running in this strand, false otherwise. If the strand is dying (destroy() has been called, returns false)

Implements qi::ExecutionContext.

void qi::Strand::join ( )

Joins the strand

This will wait for currently running tasks to finish and will drop all tasks scheduled from the moment of the call on. A strand can't be reused after it has been join()ed.

It is safe to call this method concurrently with other methods. All the returned futures will be set to error.

template<typename F >
auto qi::Strand::schedulerFor ( F &&  func,
boost::function< void()>  onFail = {} 
) -> detail::WrapInStrand<typename std::decay<F>::type>
inline

Definition at line 153 of file strand.hpp.


The documentation for this class was generated from the following file: