10#include <unordered_map>
12#include <userver/components/component_fwd.hpp>
13#include <userver/concurrent/variable.hpp>
14#include <userver/engine/task/task_with_result.hpp>
16USERVER_NAMESPACE_BEGIN
20class TaskNotFound
final :
public std::runtime_error {
21 using std::runtime_error::runtime_error;
24class TaskAlreadyRunning
final :
public std::runtime_error {
25 using std::runtime_error::runtime_error;
37class TestsuiteTasks
final {
40 using TaskCallback = std::function<
void()>;
42 explicit TestsuiteTasks(
bool is_enabled);
96 std::atomic<
bool> running_flag{
false};
97 TaskCallback callback;
101 std::atomic<
bool> busy_flag{
false};
106 std::shared_ptr<Entry> GetEntryFor(
const std::string& name);
107 std::shared_ptr<SpawnedTask> GetSpawnedFor(
const std::string& task_id);
109 const bool is_enabled_;
111 using TasksMap = std::unordered_map<std::string, std::shared_ptr<Entry>>;
112 concurrent::Variable<TasksMap> tasks_;
114 using SpawnedMap = std::unordered_map<std::string, std::shared_ptr<SpawnedTask>>;
115 concurrent::Variable<SpawnedMap> spawned_;