userver: userver/ugrpc/server/impl/queue_holder.hpp Source File
Loading...
Searching...
No Matches
queue_holder.hpp
1#pragma once
2
3#include <memory>
4
5#include <grpcpp/server_builder.h>
6
7#include <userver/ugrpc/impl/completion_queues.hpp>
8#include <userver/utils/fast_pimpl.hpp>
9
10USERVER_NAMESPACE_BEGIN
11
12namespace ugrpc::server::impl {
13
14/// @brief Manages a gRPC completion queue, usable in services and clients.
15/// @note During shutdown, `QueueHolder`s must be destroyed after
16/// `grpc::Server::Shutdown` is called, but before ugrpc::server::Reactor
17/// instances are destroyed.
18class QueueHolder final {
19 public:
20 explicit QueueHolder(std::size_t num, grpc::ServerBuilder& server_builder);
21
22 QueueHolder(QueueHolder&&) = delete;
23 QueueHolder& operator=(QueueHolder&&) = delete;
24 ~QueueHolder();
25
26 std::size_t GetSize() const;
27
28 grpc::ServerCompletionQueue& GetQueue(std::size_t i);
29
30 const ugrpc::impl::CompletionQueues& GetQueues();
31
32 private:
33 struct Impl;
34 utils::FastPimpl<Impl, 48, 8> impl_;
35};
36
37} // namespace ugrpc::server::impl
38
39USERVER_NAMESPACE_END