9#include <userver/engine/async.hpp>
10#include <userver/utils/impl/span_wrap_call.hpp>
12USERVER_NAMESPACE_BEGIN
48template <
typename Function,
typename... Args>
49[[nodiscard]]
auto Async(std::string name, Function&& f, Args&&... args) {
50 return engine::AsyncNoSpan(
51 engine::current_task::GetTaskProcessor(),
52 impl::SpanLazyPrvalue(std::move(name)),
53 std::forward<Function>(f),
54 std::forward<Args>(args)...
69template <
typename Function,
typename... Args>
70[[nodiscard]]
auto Async(engine::TaskProcessor& task_processor, std::string name, Function&& f, Args&&... args) {
71 return engine::AsyncNoSpan(
73 impl::SpanLazyPrvalue(std::move(name)),
74 std::forward<Function>(f),
75 std::forward<Args>(args)...
90template <
typename Function,
typename... Args>
92 engine::TaskProcessor& task_processor,
97 return engine::CriticalAsyncNoSpan(
99 impl::SpanLazyPrvalue(std::move(name)),
100 std::forward<Function>(f),
101 std::forward<Args>(args)...
116template <
typename Function,
typename... Args>
118 engine::TaskProcessor& task_processor,
123 return engine::SharedCriticalAsyncNoSpan(
125 impl::SpanLazyPrvalue(std::move(name)),
126 std::forward<Function>(f),
127 std::forward<Args>(args)...
142template <
typename Function,
typename... Args>
143[[nodiscard]]
auto SharedAsync(engine::TaskProcessor& task_processor, std::string name, Function&& f, Args&&... args) {
144 return engine::SharedAsyncNoSpan(
146 impl::SpanLazyPrvalue(std::move(name)),
147 std::forward<Function>(f),
148 std::forward<Args>(args)...
164template <
typename Function,
typename... Args>
166 engine::TaskProcessor& task_processor,
168 engine::Deadline deadline,
172 return engine::AsyncNoSpan(
175 impl::SpanLazyPrvalue(std::move(name)),
176 std::forward<Function>(f),
177 std::forward<Args>(args)...
193template <
typename Function,
typename... Args>
195 engine::TaskProcessor& task_processor,
197 engine::Deadline deadline,
201 return engine::SharedAsyncNoSpan(
204 impl::SpanLazyPrvalue(std::move(name)),
205 std::forward<Function>(f),
206 std::forward<Args>(args)...
220template <
typename Function,
typename... Args>
221[[nodiscard]]
auto CriticalAsync(std::string name, Function&& f, Args&&... args) {
222 return utils::CriticalAsync(
223 engine::current_task::GetTaskProcessor(),
225 std::forward<Function>(f),
226 std::forward<Args>(args)...
240template <
typename Function,
typename... Args>
242 return utils::SharedCriticalAsync(
243 engine::current_task::GetTaskProcessor(),
245 std::forward<Function>(f),
246 std::forward<Args>(args)...
260template <
typename Function,
typename... Args>
261[[nodiscard]]
auto SharedAsync(std::string name, Function&& f, Args&&... args) {
262 return utils::SharedAsync(
263 engine::current_task::GetTaskProcessor(),
265 std::forward<Function>(f),
266 std::forward<Args>(args)...
281template <
typename Function,
typename... Args>
282[[nodiscard]]
auto Async(std::string name, engine::Deadline deadline, Function&& f, Args&&... args) {
284 engine::current_task::GetTaskProcessor(),
287 std::forward<Function>(f),
288 std::forward<Args>(args)...
303template <
typename Function,
typename... Args>
304[[nodiscard]]
auto SharedAsync(std::string name, engine::Deadline deadline, Function&& f, Args&&... args) {
305 return utils::SharedAsync(
306 engine::current_task::GetTaskProcessor(),
309 std::forward<Function>(f),
310 std::forward<Args>(args)...
344template <
typename Function,
typename... Args>
347 engine::TaskProcessor& task_processor,
351 return engine::AsyncNoSpan(
353 impl::SpanLazyPrvalue(std::move(name), impl::SpanWrapCall::InheritVariables::kNo),
354 std::forward<Function>(f),
355 std::forward<Args>(args)...
372template <
typename Function,
typename... Args>
375 engine::TaskProcessor& task_processor,
379 return engine::CriticalAsyncNoSpan(
381 impl::SpanLazyPrvalue(std::move(name), impl::SpanWrapCall::InheritVariables::kNo),
382 std::forward<Function>(f),
383 std::forward<Args>(args)...