userver: userver/engine/impl/task_context_holder.hpp Source File
Loading...
Searching...
No Matches
task_context_holder.hpp
1#pragma once
2
3#include <boost/smart_ptr/intrusive_ptr.hpp>
4
5USERVER_NAMESPACE_BEGIN
6
7namespace engine::impl {
8
9class TaskContext;
10
11class TaskContextHolder final {
12 public:
13 TaskContextHolder() noexcept = default;
14
15 explicit TaskContextHolder(
16 boost::intrusive_ptr<TaskContext>&& context) noexcept;
17
18 static TaskContextHolder Adopt(TaskContext& context) noexcept;
19
20 TaskContextHolder(TaskContextHolder&&) noexcept = default;
21 TaskContextHolder& operator=(TaskContextHolder&&) = delete;
22 ~TaskContextHolder();
23
24 boost::intrusive_ptr<TaskContext>&& Extract() && noexcept;
25
26 private:
27 boost::intrusive_ptr<TaskContext> context_;
28};
29
30} // namespace engine::impl
31
32USERVER_NAMESPACE_END