userver: userver/ugrpc/server/impl/async_method_invocation.hpp Source File
Loading...
Searching...
No Matches
async_method_invocation.hpp
1#pragma once
2
3#include <grpcpp/server_context.h>
4
5#include <userver/engine/single_use_event.hpp>
6#include <userver/engine/task/cancel.hpp>
7#include <userver/ugrpc/impl/async_method_invocation.hpp>
8
9USERVER_NAMESPACE_BEGIN
10
11namespace ugrpc::server::impl {
12
13class RpcFinishedEvent final : public ugrpc::impl::EventBase {
14 public:
15 RpcFinishedEvent(engine::TaskCancellationToken cancellation_token,
16 grpc::ServerContext& server_ctx) noexcept;
17
18 RpcFinishedEvent(const RpcFinishedEvent&) = delete;
19 RpcFinishedEvent& operator=(const RpcFinishedEvent&) = delete;
20 RpcFinishedEvent(RpcFinishedEvent&&) = delete;
21 RpcFinishedEvent& operator=(RpcFinishedEvent&&) = delete;
22
23 void* GetTag() noexcept;
24
25 /// @see EventBase::Notify
26 void Notify(bool ok) noexcept override;
27
28 /// @brief For use from coroutines
29 void Wait() noexcept;
30
31 private:
32 engine::TaskCancellationToken cancellation_token_;
33 grpc::ServerContext& server_ctx_;
34 engine::SingleUseEvent event_;
35};
36
37ugrpc::impl::AsyncMethodInvocation::WaitStatus Wait(
38 ugrpc::impl::AsyncMethodInvocation& async);
39
40} // namespace ugrpc::server::impl
41
42USERVER_NAMESPACE_END