6#include <userver/engine/deadline.hpp>
7#include <userver/engine/impl/task_context_factory.hpp>
8#include <userver/engine/task/shared_task_with_result.hpp>
9#include <userver/engine/task/task_processor_fwd.hpp>
10#include <userver/engine/task/task_with_result.hpp>
11#include <userver/utils/impl/wrapped_call.hpp>
13USERVER_NAMESPACE_BEGIN
19template <
template <
typename>
typename TaskType,
typename Function,
typename... Args>
20[[nodiscard]]
auto MakeTaskWithResult(
21 TaskProcessor& task_processor,
27 using ResultType =
typename utils::impl::WrappedCallImplType<Function, Args...>::ResultType;
28 constexpr auto kWaitMode = TaskType<ResultType>::kWaitMode;
30 return TaskType<ResultType>{MakeTask(
31 {task_processor, importance, kWaitMode, deadline}, std::forward<Function>(f), std::forward<Args>(args)...
38template <
typename Function,
typename... Args>
39[[nodiscard]]
auto AsyncNoSpan(TaskProcessor& task_processor, Function&& f, Args&&... args) {
40 return impl::MakeTaskWithResult<TaskWithResult>(
41 task_processor, Task::Importance::kNormal, {}, std::forward<Function>(f), std::forward<Args>(args)...
46template <
typename Function,
typename... Args>
47[[nodiscard]]
auto SharedAsyncNoSpan(TaskProcessor& task_processor, Function&& f, Args&&... args) {
48 return impl::MakeTaskWithResult<SharedTaskWithResult>(
49 task_processor, Task::Importance::kNormal, {}, std::forward<Function>(f), std::forward<Args>(args)...
55template <
typename Function,
typename... Args>
56[[nodiscard]]
auto AsyncNoSpan(TaskProcessor& task_processor, Deadline deadline, Function&& f, Args&&... args) {
57 return impl::MakeTaskWithResult<TaskWithResult>(
58 task_processor, Task::Importance::kNormal, deadline, std::forward<Function>(f), std::forward<Args>(args)...
64template <
typename Function,
typename... Args>
65[[nodiscard]]
auto SharedAsyncNoSpan(TaskProcessor& task_processor, Deadline deadline, Function&& f, Args&&... args) {
66 return impl::MakeTaskWithResult<SharedTaskWithResult>(
67 task_processor, Task::Importance::kNormal, deadline, std::forward<Function>(f), std::forward<Args>(args)...
72template <
typename Function,
typename... Args>
74 return AsyncNoSpan(current_task::GetTaskProcessor(), std::forward<Function>(f), std::forward<Args>(args)...);
78template <
typename Function,
typename... Args>
80 return SharedAsyncNoSpan(current_task::GetTaskProcessor(), std::forward<Function>(f), std::forward<Args>(args)...);
85template <
typename Function,
typename... Args>
86[[nodiscard]]
auto AsyncNoSpan(Deadline deadline, Function&& f, Args&&... args) {
88 current_task::GetTaskProcessor(), deadline, std::forward<Function>(f), std::forward<Args>(args)...
94template <
typename Function,
typename... Args>
95[[nodiscard]]
auto SharedAsyncNoSpan(Deadline deadline, Function&& f, Args&&... args) {
96 return SharedAsyncNoSpan(
97 current_task::GetTaskProcessor(), deadline, std::forward<Function>(f), std::forward<Args>(args)...
104template <
typename Function,
typename... Args>
105[[nodiscard]]
auto CriticalAsyncNoSpan(TaskProcessor& task_processor, Function&& f, Args&&... args) {
106 return impl::MakeTaskWithResult<TaskWithResult>(
107 task_processor, Task::Importance::kCritical, {}, std::forward<Function>(f), std::forward<Args>(args)...
114template <
typename Function,
typename... Args>
115[[nodiscard]]
auto SharedCriticalAsyncNoSpan(TaskProcessor& task_processor, Function&& f, Args&&... args) {
116 return impl::MakeTaskWithResult<SharedTaskWithResult>(
117 task_processor, Task::Importance::kCritical, {}, std::forward<Function>(f), std::forward<Args>(args)...
124template <
typename Function,
typename... Args>
126 return CriticalAsyncNoSpan(
127 current_task::GetTaskProcessor(), std::forward<Function>(f), std::forward<Args>(args)...
134template <
typename Function,
typename... Args>
136 return SharedCriticalAsyncNoSpan(
137 current_task::GetTaskProcessor(), std::forward<Function>(f), std::forward<Args>(args)...
144template <
typename Function,
typename... Args>
145[[nodiscard]]
auto CriticalAsyncNoSpan(Deadline deadline, Function&& f, Args&&... args) {
146 return impl::MakeTaskWithResult<TaskWithResult>(
147 current_task::GetTaskProcessor(),
148 Task::Importance::kCritical,
150 std::forward<Function>(f),
151 std::forward<Args>(args)...