#include <userver/concurrent/background_task_storage.hpp>
A version of concurrent::BackgroundTaskStorage for advanced use cases (e.g. driver internals) that can take the ownership of any kind of task.
Definition at line 21 of file background_task_storage.hpp.
Public Member Functions | |
| BackgroundTaskStorageCore () | |
| Creates an empty BTS. | |
| BackgroundTaskStorageCore (BackgroundTaskStorageCore &&)=delete | |
| BackgroundTaskStorageCore & | operator= (BackgroundTaskStorageCore &&)=delete |
| void | CancelAndWait () noexcept |
| Explicitly cancel and wait for the tasks. New tasks must not be launched after this call returns. | |
| void | WaitAndDisposeSlow () noexcept |
| Wait for the remaining tasks to complete without cancelling them. New tasks must not be launched after this call returns. | |
| void | Detach (engine::Task &&task) |
| Detaches task, allowing it to continue execution out of scope. It will be cancelled and waited for on BTS destruction. | |
| std::int64_t | ActiveTasksApprox () const noexcept |
|
noexcept |
Can be called from a coroutine or a non-coroutine thread. Cannot be called after CancelAndWait or WaitAndDisposeSlow has been called.
|
noexcept |
Explicitly cancel and wait for the tasks. New tasks must not be launched after this call returns.
More precisely, new tasks must not be launched once this call is completed, but can be launched in the process of waiting for the remaining tasks. This means that one detached task is allowed to spawn another detached task into the same BTS, which will immediately be cancelled and for which this call will wait as well.
Can only be called from a coroutine.
| void concurrent::BackgroundTaskStorageCore::Detach | ( | engine::Task && | task | ) |
Detaches task, allowing it to continue execution out of scope. It will be cancelled and waited for on BTS destruction.
Can be called from a coroutine or a non-coroutine thread. Cannot be called after CancelAndWait or WaitAndDisposeSlow has been called.
|
noexcept |
Wait for the remaining tasks to complete without cancelling them. New tasks must not be launched after this call returns.
More precisely, new tasks must not be launched once this call is completed, but can be launched in the process of waiting for the remaining tasks. This means that one detached task is allowed to spawn another detached task into the same BTS, for which this call will wait as well.
Can only be called from a coroutine.