#include <userver/concurrent/background_task_storage.hpp>
Public Member Functions | |
BackgroundTaskStorage () | |
BackgroundTaskStorage (engine::TaskProcessor &task_processor) | |
Creates a BTS that launches tasks in the specified engine::TaskProcessor. | |
BackgroundTaskStorage (const BackgroundTaskStorage &)=delete | |
BackgroundTaskStorage & | operator= (const BackgroundTaskStorage &)=delete |
void | CancelAndWait () noexcept |
template<typename... Args> | |
void | AsyncDetach (std::string name, Args &&... args) |
Launch a task that will be cancelled and waited for in the BTS destructor. | |
std::int64_t | ActiveTasksApprox () const noexcept |
Approximate number of currently active tasks. | |
A storage that allows one to start detached tasks; cancels and waits for unfinished tasks completion at the destructor. Provides CancelAndWait to explicitly cancel tasks (recommended).
Usable for detached tasks that capture references to resources with a limited lifetime. You must guarantee that the resources are available while the BackgroundTaskStorage is alive.
Definition at line 58 of file background_task_storage.hpp.
concurrent::BackgroundTaskStorage::BackgroundTaskStorage | ( | ) |
Creates a BTS that launches tasks in the engine::TaskProcessor used at the BTS creation.
|
inline |
Launch a task that will be cancelled and waited for in the BTS destructor.
The task is started as non-Critical, it may be cancelled due to TaskProcessor
overload. engine::TaskInheritedVariable instances are not inherited from the caller. See utils::AsyncBackground for details.
Definition at line 81 of file background_task_storage.hpp.
|
noexcept |
Explicitly cancel and wait for the tasks. New tasks must not be launched after this call returns. Should be called no more than once.