3#ifndef ICE_ASYNC_RESPONSE_HANDLER_H
4#define ICE_ASYNC_RESPONSE_HANDLER_H
7#include "LocalExceptions.h"
8#include "OutgoingResponse.h"
17 class AsyncResponseHandler final
21 AsyncResponseHandler(std::function<
void(Ice::OutgoingResponse)> sendResponse, Ice::Current current)
22 : _sendResponse(std::move(sendResponse)),
23 _current(std::move(current))
27 void sendEmptyResponse() noexcept
29 if (!_responseSent.test_and_set())
36 void sendResponse(Ice::MarshaledResult marshaledResult)
noexcept
38 if (!_responseSent.test_and_set())
40 _sendResponse(Ice::OutgoingResponse{std::move(marshaledResult).outputStream(), _current});
45 void sendResponse(
bool ok, std::pair<const std::byte*, const std::byte*> encaps)
noexcept
47 if (!_responseSent.test_and_set())
55 const std::function<
void(Ice::OutputStream*)>& marshal,
56 std::optional<Ice::FormatType> format = std::nullopt)
noexcept
60 if (!_responseSent.test_and_set())
67 void sendException(std::exception_ptr ex)
noexcept
69 if (!_responseSent.test_and_set())
76 [[nodiscard]]
const Ice::Current& current() const noexcept {
return _current; }
79 const std::function<void(Ice::OutgoingResponse)> _sendResponse;
80 const Ice::Current _current;
81 std::atomic_flag _responseSent = ATOMIC_FLAG_INIT;
OutgoingResponse makeOutgoingResponse(const std::function< void(OutputStream *)> &marshal, const Current ¤t, std::optional< FormatType > format=std::nullopt) noexcept
Creates an OutgoingResponse object with ReplyStatus::Ok.
OutgoingResponse makeEmptyOutgoingResponse(const Current ¤t) noexcept
Creates an OutgoingResponse object with ReplyStatus::Ok and an empty payload.