|
Leosac
0.7.0
OpenSourceAccessControl
|
A base class for a tasks. More...
#include <Task.hpp>
Inheritance diagram for Leosac::Tasks::Task:
Collaboration diagram for Leosac::Tasks::Task:Public Member Functions | |
| Task () | |
| virtual | ~Task () |
| Task (const Task &)=delete | |
| Task (Task &&)=delete | |
| Task & | operator= (const Task &)=delete |
| Task & | operator= (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 |
Private Member Functions | |
| virtual bool | do_run ()=0 |
Private Attributes | |
| std::function< void(void)> | on_completion_ |
| std::function< void(void)> | on_success_ |
| std::function< void(void)> | on_failure_ |
| bool | success_ |
| std::exception_ptr | eptr_ |
| std::mutex | mutex_ |
| std::atomic_bool | complete_ |
| std::condition_variable | cv_ |
| std::string | guid_ |
A base class for a tasks.
It makes use of the Non Virtual Interface pattern to let subclasses implement the task code while it wraps it properly and take care of notifications.
|
delete |
|
delete |
|
privatepure virtual |
| bool Task::is_complete | ( | ) | const |
|
inline |
|
inline |
|
inline |
| void Task::wait | ( | ) |
Instead of spinlocking over is_complete() one can call wait() to hum...
wait for the task's completion.
This is implemented using some condition_variable magic.
|
private |
|
private |
|
private |