Resilient
Public Member Functions | Related Functions | List of all members
resilient::Task< Callable, FailureDetector > Class Template Reference

Create a task from a callable, using a Detector to detect failures. More...

#include <task.hpp>

Public Member Functions

 Task (Callable &&callable, FailureDetector &&detector)
 Instantiate a new Task with the given callable and failure detector. More...
 
template<typename NewFailureDetector >
Task< Callable, NewFailureDetector > failsIf (NewFailureDetector &&condition)&&
 Create a new task using the current callable and a new failure condition. More...
 
template<typename... Args>
auto operator() (Args &&...args)&
 Invoke the callable checking for failures. More...
 
template<typename... Args>
auto operator() (Args &&...args)&&
 Same as operator()&, but also forwards the callable when invoking it.
 

Related Functions

(Note that these are not member functions.)

template<typename Callable , typename FailureDetector = NoFailureDetector>
Task< Callable, FailureDetector > task (Callable &&callable, FailureDetector &&detector=FailureDetector())
 Wrap a callable object in a Task. More...
 

Detailed Description

template<typename Callable, typename FailureDetector>
class resilient::Task< Callable, FailureDetector >

Create a task from a callable, using a Detector to detect failures.

Wrap a callable object, making it return a Failable when invoked.

Task uses a detector to detect whether the invocation of the callable failed or not.

Template Parameters
CallableThe callable object which will be used when invoking the task.
FailureDetectorThe detector that will be used to detect failures when invoking the callable.

Constructor & Destructor Documentation

template<typename Callable , typename FailureDetector >
resilient::Task< Callable, FailureDetector >::Task ( Callable &&  callable,
FailureDetector &&  detector 
)
inline

Instantiate a new Task with the given callable and failure detector.

Note
The preferred way to create a Task is to use the task() function.
Parameters
callableThe callable to use.
detectorThe detector to use.

Member Function Documentation

template<typename Callable , typename FailureDetector >
template<typename NewFailureDetector >
Task<Callable, NewFailureDetector> resilient::Task< Callable, FailureDetector >::failsIf ( NewFailureDetector &&  condition)
inline

Create a new task using the current callable and a new failure condition.

Precondition
It only compiles if the current Task has no failure condition assigned.
Parameters
conditionThe new failure condition.
Returns
The new Task
template<typename Callable , typename FailureDetector >
template<typename... Args>
auto resilient::Task< Callable, FailureDetector >::operator() ( Args &&...  args)
inline

Invoke the callable checking for failures.

Parameters
argsThe arguments to be used when invoking the callable.

Friends And Related Function Documentation

template<typename Callable , typename FailureDetector = NoFailureDetector>
Task< Callable, FailureDetector > task ( Callable &&  callable,
FailureDetector &&  detector = FailureDetector() 
)
related

Wrap a callable object in a Task.

Parameters
callableThe callable to wrap.
detectorThe detector to use.
Returns
The Task wrapping the callable and using the provided detector. If no detector is provided a task with no detector is returned. In such a case you need to invoke failsIf() on the task to provide a detector, otherwise the Task will not compile.

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