#include <userver/testsuite/tasks.hpp>
Testsuite tasks support. 
A testsuite task is a function that can be called from testsuite by its name. Only one task with the same name can be run simultaneously. 
Definition at line 37 of file tasks.hpp.
 | 
| using  | TaskCallback = std::function<void()> | 
|   | Task function type.  
  | 
|   | 
 | 
| 
  | TestsuiteTasks (bool is_enabled) | 
|   | 
| bool  | IsEnabled () const | 
|   | Are testsuite tasks enabled or not.  
  | 
|   | 
| void  | RegisterTask (const std::string &name, TaskCallback callback) | 
|   | Register new task.  
  | 
|   | 
| void  | UnregisterTask (const std::string &name) | 
|   | Unregister task.  
  | 
|   | 
| void  | RunTask (const std::string &name) | 
|   | Run task by name and waits for it to finish.  
  | 
|   | 
| std::string  | SpawnTask (const std::string &name) | 
|   | Asynchronously starts the task.  
  | 
|   | 
| void  | StopSpawnedTask (const std::string &task_id) | 
|   | Stop previously spawned task.  
  | 
|   | 
| void  | CheckNoRunningTasks () noexcept | 
|   | Checks that there are no running tasks left.  
  | 
|   | 
| 
std::vector< std::string >  | GetTaskNames () const | 
|   | Returns list of registered task names. 
  | 
|   | 
◆ TaskCallback
Task function type. 
Definition at line 40 of file tasks.hpp.
 
 
◆ CheckNoRunningTasks()
  
  
      
        
          | void testsuite::TestsuiteTasks::CheckNoRunningTasks  | 
          ( | 
           | ) | 
           | 
         
       
   | 
  
noexcept   | 
  
 
Checks that there are no running tasks left. 
Must be called on service shutdown. Aborts process when there are tasks running. 
 
 
◆ IsEnabled()
  
  
      
        
          | bool testsuite::TestsuiteTasks::IsEnabled  | 
          ( | 
           | ) | 
           const | 
         
       
   | 
  
inline   | 
  
 
Are testsuite tasks enabled or not. 
It is recommended to register tasks only for testsuite environment. Use this method to test weather or not you are running under testsuite: 
if (testsuite_tasks.IsEnabled()) {
  
} else {
  
}
  
Definition at line 56 of file tasks.hpp.
 
 
◆ RegisterTask()
      
        
          | void testsuite::TestsuiteTasks::RegisterTask  | 
          ( | 
          const std::string & |           name,  | 
        
        
           | 
           | 
          TaskCallback |           callback ) | 
        
      
 
Register new task. 
- Parameters
 - 
  
    | name | Task name  | 
    | callback | Testsuite task callback function  | 
  
   
- Exceptions
 - 
  
    | std::runtime_error | When task with name is already registered.  | 
  
   
 
 
◆ RunTask()
      
        
          | void testsuite::TestsuiteTasks::RunTask  | 
          ( | 
          const std::string & |           name | ) | 
           | 
        
      
 
Run task by name and waits for it to finish. 
- Parameters
 - 
  
  
 
- Exceptions
 - 
  
  
 
 
 
◆ SpawnTask()
      
        
          | std::string testsuite::TestsuiteTasks::SpawnTask  | 
          ( | 
          const std::string & |           name | ) | 
           | 
        
      
 
Asynchronously starts the task. 
- Parameters
 - 
  
  
 
- Returns
 - Task id 
 
- Exceptions
 - 
  
  
 
 
 
◆ StopSpawnedTask()
      
        
          | void testsuite::TestsuiteTasks::StopSpawnedTask  | 
          ( | 
          const std::string & |           task_id | ) | 
           | 
        
      
 
Stop previously spawned task. 
- Parameters
 - 
  
  
 
- Exceptions
 - 
  
  
 
 
 
◆ UnregisterTask()
      
        
          | void testsuite::TestsuiteTasks::UnregisterTask  | 
          ( | 
          const std::string & |           name | ) | 
           | 
        
      
 
Unregister task. 
- Parameters
 - 
  
  
 
- Exceptions
 - 
  
    | std::runtime_error | When task name is not known.  | 
  
   
 
 
The documentation for this class was generated from the following file: