userver: userver/engine/task/shared_task.hpp Source File
Loading...
Searching...
No Matches
shared_task.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <memory>
7#include <type_traits>
8#include <utility>
9
10#include <userver/engine/impl/task_context_holder.hpp>
13
14USERVER_NAMESPACE_BEGIN
15
16namespace engine {
17
27class [[nodiscard]] SharedTask : public TaskBase {
28public:
33
37
39 SharedTask(const SharedTask& other) noexcept;
40
46 SharedTask& operator=(const SharedTask& other) noexcept;
47
50 SharedTask(SharedTask&& other) noexcept;
51
57 SharedTask& operator=(SharedTask&& other) noexcept;
58
60 AwaitableToken GetAwaitableToken() noexcept USERVER_IMPL_LIFETIME_BOUND;
61
63 static constexpr WaitMode kWaitMode = WaitMode::kMultipleAwaiters;
64
65protected:
66 // For internal use only.
67 explicit SharedTask(impl::TaskContextHolder&& context);
69
70private:
71 void DecrementSharedUsages() noexcept;
72 void IncrementSharedUsages() noexcept;
73};
74
75} // namespace engine
76
77USERVER_NAMESPACE_END