Leosac  0.8.0
Open Source Access Control
Leosac::Tasks::GenericTask Class Reference

This task type is used whenever a lambda is passed to the scheduler. More...

#include <GenericTask.hpp>

+ Inheritance diagram for Leosac::Tasks::GenericTask:
+ Collaboration diagram for Leosac::Tasks::GenericTask:

Public Member Functions

 GenericTask (const std::function< bool(void)> &fct)
 
- Public Member Functions inherited from Leosac::Tasks::Task
 Task ()
 
virtual ~Task ()
 
 Task (const Task &)=delete
 
 Task (Task &&)=delete
 
Taskoperator= (const Task &)=delete
 
Taskoperator= (Task &&)=delete
 
bool is_complete () const
 Has the tasks completed its execution. More...
 
void wait ()
 Instead of spinlocking over is_complete() one can call wait() to hum... More...
 
void run ()
 
bool succeed () const
 
std::exception_ptr get_exception () const
 
template<typename Callback >
void set_on_completion (Callback c)
 Set a callback that will be invoked when the tasks is completed, no matter if it succeeded or not. More...
 
template<typename Callback >
void set_on_success (Callback c)
 Set a callback that will be invoked if and when the task succeed. More...
 
template<typename Callback >
void set_on_failure (Callback c)
 Set a callback that will be invoked if and when the task fails. More...
 
const std::string & get_guid () const
 

Static Public Member Functions

template<typename Callable >
static TaskPtr build (const Callable &callable)
 

Private Member Functions

virtual bool do_run ()
 

Private Attributes

std::function< bool(void)> fct_
 

Detailed Description

This task type is used whenever a lambda is passed to the scheduler.

The scheduler use std::function to type-erase the callable object so that it can fit into GenericTask.

Definition at line 35 of file GenericTask.hpp.

Constructor & Destructor Documentation

◆ GenericTask()

Leosac::Tasks::GenericTask::GenericTask ( const std::function< bool(void)> &  fct)

Definition at line 23 of file GenericTask.cpp.

Member Function Documentation

◆ build()

template<typename Callable >
static TaskPtr Leosac::Tasks::GenericTask::build ( const Callable &  callable)
inlinestatic

Definition at line 41 of file GenericTask.hpp.

◆ do_run()

bool Leosac::Tasks::GenericTask::do_run ( )
privatevirtual

Implements Leosac::Tasks::Task.

Definition at line 29 of file GenericTask.cpp.

Member Data Documentation

◆ fct_

std::function<bool(void)> Leosac::Tasks::GenericTask::fct_
private

Definition at line 49 of file GenericTask.hpp.


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