libqi-api  2.4.3.28
 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 ()
 
void post (const boost::function< void()> &callback)
 post a callback to be executed as soon as possible More...
 
qi::Future< void > async (const boost::function< void()> &cb, qi::SteadyClockTimePoint tp)
 call a callback asynchronously to be executed on tp More...
 
qi::Future< void > async (const boost::function< void()> &cb, qi::Duration delay=qi::Duration(0))
 call a callback asynchronously to be executed in delay More...
 
bool isInThisContext ()
 return true if the current thread is in this context More...
 
- Public Member Functions inherited from qi::ExecutionContext
virtual ~ExecutionContext ()
 
template<typename R >
boost::disable_if
< boost::is_same< R, void >
, qi::Future< R > >::type 
async (const boost::function< R()> &callback, qi::Duration delay=qi::Duration(0))
 call a callback asynchronously to be executed in delay More...
 
template<typename R >
boost::disable_if
< boost::is_same< R, void >
, qi::Future< R > >::type 
async (const boost::function< R()> &callback, qi::SteadyClockTimePoint tp)
 call a callback asynchronously to be executed on tp More...
 

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 31 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 ( )

Destroys the strand

This will wait for all scheduled tasks to finish

Member Function Documentation

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

call a callback asynchronously to be executed on tp

Implements qi::ExecutionContext.

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

call a callback asynchronously to be executed in delay

Implements qi::ExecutionContext.

bool qi::Strand::isInThisContext ( )
virtual

return true if the current thread is in this context

Implements qi::ExecutionContext.

void qi::Strand::post ( const boost::function< void()> &  callback)
virtual

post a callback to be executed as soon as possible

Implements qi::ExecutionContext.


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