AIStatefulTask ‐ Asynchronous, Stateful Task Scheduler library.

Threads-like task objects evolving through user-defined states.

Public Member Functions | List of all members
AIDelayedFunction< R(Args...)> Class Template Reference

Detailed Description

template<typename R, typename ... Args>
class AIDelayedFunction< R(Args...)>

Helper class for AIPackagedTask.

This object reserves storage a function pointer, its arguments and a return value.

The function pointer is initialized at creation, the arguments are added later.

The actual invokation of the function happens by calling the invoke() member function, which stores the return value once again in this object.

The return value can later be obtained through the member function get().

Usage example:

AIDelayedFunction<char(int, double)> delayed_function(&f); // char f(int, double);
AIDelayedFunction(R(*fp)(Args...))
Construct an AIDelayedFunction for a free function <span class="inlinecode">R f(Args....
Definition: AIDelayedFunction.h:87

or

AIDelayedFunction<char(int, double)> delayed_function(&obj, &C::f); // char C::f(int, double); where obj is of type C.
delayed_function(1, 1.0); // Store the arguments.
delayed_function.invoke(); // Call f(1, 1.0) or obj.f(1, 1.0) and store the result.
char c = delayed_function.get(); // Get the result.

#include <AIDelayedFunction.h>

Public Member Functions

 AIDelayedFunction (R(*fp)(Args...))
 Construct an AIDelayedFunction for a free function R f(Args...).
 
template<class C >
 AIDelayedFunction (C *object, R(C::*memfn)(Args...))
 
void swap (AIDelayedFunction &other) noexcept
 Exchange the state with that of other.
 
void operator() (Args... args)
 Store the arguments to be passed.
 
void invoke ()
 Actually invoke the call to the stored function with the stored arguments.
 
R const & get () const
 Get the result, only valid after invoke was called.
 

Constructor & Destructor Documentation

◆ AIDelayedFunction()

template<typename R , typename ... Args>
template<class C >
AIDelayedFunction< R(Args...)>::AIDelayedFunction ( C *  object,
R(C::*)(Args...)  memfn 
)
inline

Construct an AIDelayedFunction for a member function R C::f(Args...) of object.

The object must have a lifetime that exceeds the call to invoke.


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