#include <userver/utils/task_builder.hpp>
Builder class for engine::Task and engine::TaskWithResult. Use it if you want to build a task with complex properties or even the property values are determined at runtime. If you just want to start a task, use utils::Async or engine::AsyncNoSpan.
Definition at line 27 of file task_builder.hpp.
Public Member Functions | |
| TaskBuilder (const TaskBuilder &)=default | |
| TaskBuilder (TaskBuilder &&)=default | |
| TaskBuilder & | operator= (const TaskBuilder &)=default |
| TaskBuilder & | operator= (TaskBuilder &&)=default |
| TaskBuilder & | Critical () USERVER_IMPL_LIFETIME_BOUND |
| TaskBuilder & | SpanName (std::string &&name) USERVER_IMPL_LIFETIME_BOUND |
| TaskBuilder & | HideSpan () USERVER_IMPL_LIFETIME_BOUND |
| TaskBuilder & | NoSpan () USERVER_IMPL_LIFETIME_BOUND |
| TaskBuilder & | TaskProcessor (engine::TaskProcessor &tp) USERVER_IMPL_LIFETIME_BOUND |
| TaskBuilder & | Deadline (engine::Deadline deadline) USERVER_IMPL_LIFETIME_BOUND |
| TaskBuilder & | Background () USERVER_IMPL_LIFETIME_BOUND |
| template<typename Function, typename... Args> | |
| auto | Build (Function &&f, Args &&... args) |
| template<typename Function, typename... Args> | |
| auto | BuildShared (Function &&f, Args &&... args) |
| TaskBuilder & utils::TaskBuilder::Background | ( | ) |
The following call to Build will spawn a background task without propagating engine::TaskInheritedVariable. tracing::Span and baggage::Baggage are inherited.
| auto utils::TaskBuilder::Build | ( | Function && | f, |
| Args &&... | args ) |
Setup and return the task. It doesn't drop the previous settings, so it can be called multiple times.
By default, arguments are copied or moved inside the resulting TaskWithResult, like std::thread does. To pass an argument by reference, wrap it in std::ref / std::cref or capture the arguments using a lambda.
Definition at line 127 of file task_builder.hpp.
| auto utils::TaskBuilder::BuildShared | ( | Function && | f, |
| Args &&... | args ) |
Setup and return the task. It doesn't drop the previous settings, so it can be called multiple times.
By default, arguments are copied or moved inside the resulting TaskWithResult, like std::thread does. To pass an argument by reference, wrap it in std::ref / std::cref or capture the arguments using a lambda.
Definition at line 133 of file task_builder.hpp.
| TaskBuilder & utils::TaskBuilder::Critical | ( | ) |
Set "critical" flag for the new task.
| TaskBuilder & utils::TaskBuilder::Deadline | ( | engine::Deadline | deadline | ) |
The following call to Build will spawn a task that has a defined deadline. If the deadline expires, the task is cancelled. See *Async* function signatures for details.
| TaskBuilder & utils::TaskBuilder::HideSpan | ( | ) |
The following call to Build will spawn a task with tracing::Span, but with logging::Level::kNone log level (it hides the span log itself, but not logs within the span). Logs will then be linked to the nearest span that is written out.
| TaskBuilder & utils::TaskBuilder::NoSpan | ( | ) |
The following call to Build will spawn a task without any tracing::Span.
| TaskBuilder & utils::TaskBuilder::SpanName | ( | std::string && | name | ) |
The following call to Build will spawn a task with tracing::Span with the passed name.
| TaskBuilder & utils::TaskBuilder::TaskProcessor | ( | engine::TaskProcessor & | tp | ) |
The following call to Build will spawn a task inside the defined task processor. If not called, engine::current_task::GetTaskProcessor is used by default.