LeechCraft  0.6.70-6645-gcd10d7e
Modular cross-platform feature rich live environment.
LeechCraft::Util::detail::Sequencer< Future > Class Template Reference

Incapsulates the sequencing logic of asynchronous actions. More...

#include "futures.h"

+ Inheritance diagram for LeechCraft::Util::detail::Sequencer< Future >:
+ Collaboration diagram for LeechCraft::Util::detail::Sequencer< Future >:

Public Types

using RetType_t = UnwrapFutureType_t< Future >
 The type instantinating the QFuture returned by the Executor. More...
 

Public Member Functions

 Sequencer (const Future &future, QObject *parent)
 Constructs the sequencer. More...
 
void Start ()
 Starts the first action in the chain. More...
 
template<typename RetT , typename ArgT >
void Then (const std::function< QFuture< RetT >(ArgT)> &action)
 Chains the given asynchronous action. More...
 
template<typename ArgT >
void Then (const std::function< void(ArgT)> &action)
 Chains the given asynchronous action and closes the chain. More...
 
void Then (const std::function< void()> &action)
 

Detailed Description

template<typename Future>
class LeechCraft::Util::detail::Sequencer< Future >

Incapsulates the sequencing logic of asynchronous actions.

The objects of this class are expected to be created on heap. They will delete themselves automatically after the chain is walked (or an exception is thrown).

Template Parameters
ExecutorThe type of the initial functor in the async call chain.
ArgsThe types of the arguments that should be passed to the Executor.

Definition at line 237 of file futures.h.

Member Typedef Documentation

template<typename Future>
using LeechCraft::Util::detail::Sequencer< Future >::RetType_t = UnwrapFutureType_t<Future>

The type instantinating the QFuture returned by the Executor.

Definition at line 243 of file futures.h.

Constructor & Destructor Documentation

template<typename Future>
LeechCraft::Util::detail::Sequencer< Future >::Sequencer ( const Future &  future,
QObject *  parent 
)
inline

Constructs the sequencer.

Parameters
[in]fThe first action in the chain.
[in]argsThe arguments to the action.
[in]parentThe parent object for the sequencer.

Definition at line 255 of file futures.h.

Member Function Documentation

template<typename Future>
void LeechCraft::Util::detail::Sequencer< Future >::Start ( )
inline

Starts the first action in the chain.

All the actions should be chained before calling this method to avoid a race condition.

Definition at line 267 of file futures.h.

Referenced by LeechCraft::Util::detail::SequenceProxy< Ret, Future, DestructionTag >::SequenceProxy().

+ Here is the caller graph for this function:

template<typename Future>
template<typename RetT , typename ArgT >
void LeechCraft::Util::detail::Sequencer< Future >::Then ( const std::function< QFuture< RetT >(ArgT)> &  action)
inline

Chains the given asynchronous action.

The action is a functor callable with a single parameter of type ArgT and returning a value of type QFuture<RetT> for some RetT.

The parameter type ArgT should match exactly the "unwrapped" RetT for the previous call of Then() (or RetType_t if this is the second action in the asynchronous chain). Otherwise, an exception will be thrown at runtime.

Note
The SequenceProxy class takes care of compile-time type-checking of arguments and return types.
Parameters
[in]actionThe action to add to the sequence chain.
Template Parameters
RetTThe type instantiating the return type QFuture<RetT> of the action.
ArgTThe type of the argument passed to the action.

Definition at line 293 of file futures.h.

template<typename Future>
template<typename ArgT >
void LeechCraft::Util::detail::Sequencer< Future >::Then ( const std::function< void(ArgT)> &  action)
inline

Chains the given asynchronous action and closes the chain.

The action is a functor callable with a single parameter of type ArgT and returning void.

No more functors may be chained after adding a void-returning functor.

The parameter type ArgT should match exactly the "unwrapped" RetT for the previous call of Then() (or RetType_t if this is the second action in the asynchronous chain). Otherwise, an exception will be thrown at runtime.

Note
The SequenceProxy class takes care of compile-time type-checking of arguments and return types.
Template Parameters
ArgTThe type of the argument passed to the action.

Definition at line 340 of file futures.h.

template<typename Future>
void LeechCraft::Util::detail::Sequencer< Future >::Then ( const std::function< void()> &  action)
inline

Definition at line 362 of file futures.h.


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