14USERVER_NAMESPACE_BEGIN
23 enum class InheritVariables { kYes, kNo };
25 explicit SpanWrapCall(std::string&& name, InheritVariables inherit_variables);
27 SpanWrapCall(
const SpanWrapCall&) =
delete;
28 SpanWrapCall(SpanWrapCall&&) =
delete;
29 SpanWrapCall& operator=(
const SpanWrapCall&) =
delete;
30 SpanWrapCall& operator=(SpanWrapCall&&) =
delete;
33 template <
typename Function,
typename... Args>
34 auto operator()(Function&& f, Args&&... args) {
36 return std::invoke(std::forward<Function>(f), std::forward<Args>(args)...);
40 void DoBeforeInvoke();
44 static constexpr std::size_t kImplSize = 4240;
45 static constexpr std::size_t kImplAlign = 8;
50inline auto SpanLazyPrvalue(std::string&& name) {
52 return SpanWrapCall(std::move(name), SpanWrapCall::InheritVariables::kYes);
74template <
typename Function,
typename... Args>
76 std::string name, Function&& f,
79 task_processor, impl::SpanLazyPrvalue(std::move(name)),
80 std::forward<Function>(f), std::forward<Args>(args)...);
100template <
typename Function,
typename... Args>
102 std::string name, Function&& f,
105 task_processor, impl::SpanLazyPrvalue(std::move(name)),
106 std::forward<Function>(f), std::forward<Args>(args)...);
126template <
typename Function,
typename... Args>
127[[nodiscard]]
auto Async(engine::TaskProcessor& task_processor,
128 std::string name, Function&& f, Args&&... args) {
130 task_processor, impl::SpanLazyPrvalue(std::move(name)),
131 std::forward<Function>(f), std::forward<Args>(args)...);
152template <
typename Function,
typename... Args>
153[[nodiscard]]
auto SharedAsync(engine::TaskProcessor& task_processor,
154 std::string name, Function&& f, Args&&... args) {
156 task_processor, impl::SpanLazyPrvalue(std::move(name)),
157 std::forward<Function>(f), std::forward<Args>(args)...);
174template <
typename Function,
typename... Args>
175[[nodiscard]]
auto Async(engine::TaskProcessor& task_processor,
177 Function&& f, Args&&... args) {
179 task_processor, deadline, impl::SpanLazyPrvalue(std::move(name)),
180 std::forward<Function>(f), std::forward<Args>(args)...);
198template <
typename Function,
typename... Args>
199[[nodiscard]]
auto SharedAsync(engine::TaskProcessor& task_processor,
201 Function&& f, Args&&... args) {
203 task_processor, deadline, impl::SpanLazyPrvalue(std::move(name)),
204 std::forward<Function>(f), std::forward<Args>(args)...);
223template <
typename Function,
typename... Args>
227 std::move(name), std::forward<Function>(f),
228 std::forward<Args>(args)...);
248template <
typename Function,
typename... Args>
252 std::move(name), std::forward<Function>(f),
253 std::forward<Args>(args)...);
273template <
typename Function,
typename... Args>
274[[nodiscard]]
auto Async(std::string name, Function&& f, Args&&... args) {
275 return utils::Async(engine::current_task::GetTaskProcessor(), std::move(name),
276 std::forward<Function>(f), std::forward<Args>(args)...);
297template <
typename Function,
typename... Args>
298[[nodiscard]]
auto SharedAsync(std::string name, Function&& f, Args&&... args) {
300 std::move(name), std::forward<Function>(f),
301 std::forward<Args>(args)...);
318template <
typename Function,
typename... Args>
320 Function&& f, Args&&... args) {
321 return utils::Async(engine::current_task::GetTaskProcessor(), std::move(name),
322 deadline, std::forward<Function>(f),
323 std::forward<Args>(args)...);
341template <
typename Function,
typename... Args>
343 Function&& f, Args&&... args) {
345 engine::current_task::GetTaskProcessor(), std::move(name), deadline,
346 std::forward<Function>(f), std::forward<Args>(args)...);
379template <
typename Function,
typename... Args>
381 engine::TaskProcessor& task_processor,
382 Function&& f, Args&&... args) {
385 return impl::SpanWrapCall(std::move(name),
386 impl::SpanWrapCall::InheritVariables::kNo);
388 std::forward<Function>(f), std::forward<Args>(args)...);