6#include <userver/ugrpc/client/rpc.hpp>
12template <
typename Response>
13class [[nodiscard]] ResponseFuture final {
17 explicit ResponseFuture(UnaryCall<Response>&& call);
23 [[nodiscard]]
bool IsReady()
const noexcept;
46 engine::impl::ContextAccessor* TryGetContextAccessor()
noexcept;
50 UnaryCall<Response> call_;
51 std::unique_ptr<Response> response_;
55template <
typename Response>
56ResponseFuture<Response>::ResponseFuture(UnaryCall<Response>&& call)
57 : call_{std::move(call)}, response_{std::make_unique<Response>()}, future_{call_.FinishAsync(*response_)} {}
59template <
typename Response>
60bool ResponseFuture<Response>::
IsReady()
const noexcept {
61 return future_.IsReady();
64template <
typename Response>
66 return future_.WaitUntil(deadline);
69template <
typename Response>
70Response ResponseFuture<Response>::
Get() {
72 return std::move(*response_);
75template <
typename Response>
80template <
typename Response>
81engine::impl::ContextAccessor* ResponseFuture<Response>::TryGetContextAccessor()
noexcept {
82 return future_.TryGetContextAccessor();