diff --git a/src/agrpc/alarm.hpp b/src/agrpc/alarm.hpp index b832556b..bd3c73d2 100644 --- a/src/agrpc/alarm.hpp +++ b/src/agrpc/alarm.hpp @@ -80,7 +80,7 @@ class BasicAlarm * completion signature is `void(bool)`. `true` if it expired, `false` if it was canceled. */ template > - auto wait(const Deadline& deadline, CompletionToken&& token = detail::DefaultCompletionTokenT{}) & + auto wait(const Deadline& deadline, CompletionToken&& token = CompletionToken{}) & { using Initiation = detail::GrpcSenderInitiation>; if constexpr (std::is_same_v>) @@ -110,7 +110,7 @@ class BasicAlarm * completion signature is `void(bool, BasicAlarm)`. `true` if it expired, `false` if it was canceled. */ template > - auto wait(const Deadline& deadline, CompletionToken&& token = detail::DefaultCompletionTokenT{}) && + auto wait(const Deadline& deadline, CompletionToken&& token = CompletionToken{}) && { using Initiation = detail::MoveAlarmSenderInitiation; if constexpr (std::is_same_v>) diff --git a/src/agrpc/client_rpc.hpp b/src/agrpc/client_rpc.hpp index 8fa63a7d..d2a8ddc1 100644 --- a/src/agrpc/client_rpc.hpp +++ b/src/agrpc/client_rpc.hpp @@ -129,8 +129,7 @@ class ClientRPCUnaryBase : public detail::ClientRPC */ template > static auto request(agrpc::GrpcContext& grpc_context, StubT& stub, grpc::ClientContext& context, - const RequestT& request, ResponseT& response, - CompletionToken&& token = detail::DefaultCompletionTokenT{}) + const RequestT& request, ResponseT& response, CompletionToken&& token = CompletionToken{}) { return detail::async_initiate_sender_implementation( grpc_context, detail::ClientUnaryRequestSenderInitiation{context, response}, @@ -143,7 +142,7 @@ class ClientRPCUnaryBase : public detail::ClientRPC */ template > static auto request(const Executor& executor, StubT& stub, grpc::ClientContext& context, const RequestT& request, - ResponseT& response, CompletionToken&& token = detail::DefaultCompletionTokenT{}) + ResponseT& response, CompletionToken&& token = CompletionToken{}) { return ClientRPCUnaryBase::request(detail::query_grpc_context(executor), stub, context, request, response, static_cast(token)); @@ -184,7 +183,7 @@ class ClientRPCUnaryBase : public detail::ClientRPC * completion signature is `void(grpc::Status)`. */ template > - auto finish(ResponseT& response, CompletionToken&& token = detail::DefaultCompletionTokenT{}) + auto finish(ResponseT& response, CompletionToken&& token = CompletionToken{}) { return detail::async_initiate_sender_implementation( this->grpc_context(), detail::ClientFinishUnarySenderInitation{response}, @@ -320,7 +319,7 @@ class ClientRPC template > static auto request(agrpc::GrpcContext& grpc_context, const std::string& method, grpc::GenericStub& stub, grpc::ClientContext& context, const grpc::ByteBuffer& request, grpc::ByteBuffer& response, - CompletionToken&& token = detail::DefaultCompletionTokenT{}) + CompletionToken&& token = CompletionToken{}) { return detail::async_initiate_sender_implementation( grpc_context, detail::ClientUnaryRequestSenderInitiation{context, response}, @@ -334,7 +333,7 @@ class ClientRPC template > static auto request(const Executor& executor, const std::string& method, grpc::GenericStub& stub, grpc::ClientContext& context, const grpc::ByteBuffer& request, grpc::ByteBuffer& response, - CompletionToken&& token = detail::DefaultCompletionTokenT{}) + CompletionToken&& token = CompletionToken{}) { return ClientRPC::request(detail::query_grpc_context(executor), method, stub, context, request, response, static_cast(token)); @@ -376,7 +375,7 @@ class ClientRPC * completion signature is `void(grpc::Status)`. */ template > - auto finish(grpc::ByteBuffer& response, CompletionToken&& token = detail::DefaultCompletionTokenT{}) + auto finish(grpc::ByteBuffer& response, CompletionToken&& token = CompletionToken{}) { return detail::async_initiate_sender_implementation( this->grpc_context(), detail::ClientFinishUnarySenderInitation{response}, @@ -513,7 +512,7 @@ class ClientRPC : public detail::ClientRP * error details. */ template > - auto start(StubT& stub, ResponseT& response, CompletionToken&& token = detail::DefaultCompletionTokenT{}) + auto start(StubT& stub, ResponseT& response, CompletionToken&& token = CompletionToken{}) { return detail::async_initiate_sender_implementation( this->grpc_context(), @@ -542,7 +541,7 @@ class ClientRPC : public detail::ClientRP * `void(bool)`. `true` indicates that the metadata was read. If it is `false`, then the call is dead. */ template > - auto read_initial_metadata(CompletionToken&& token = detail::DefaultCompletionTokenT{}) + auto read_initial_metadata(CompletionToken&& token = CompletionToken{}) { return detail::async_initiate_sender_implementation( this->grpc_context(), detail::ClientReadInitialMetadataWritableStreamSenderInitiation{}, @@ -557,8 +556,7 @@ class ClientRPC : public detail::ClientRP * `write(request, token)`. */ template > - auto write(const RequestT& request, grpc::WriteOptions options, - CompletionToken&& token = detail::DefaultCompletionTokenT{}) + auto write(const RequestT& request, grpc::WriteOptions options, CompletionToken&& token = CompletionToken{}) { return detail::async_initiate_sender_implementation( this->grpc_context(), detail::ClientWriteSenderInitiation{request, options}, @@ -578,7 +576,7 @@ class ClientRPC : public detail::ClientRP * channel, etc). */ template > - auto write(const RequestT& request, CompletionToken&& token = detail::DefaultCompletionTokenT{}) + auto write(const RequestT& request, CompletionToken&& token = CompletionToken{}) { return write(request, grpc::WriteOptions{}, static_cast(token)); } @@ -608,7 +606,7 @@ class ClientRPC : public detail::ClientRP * completion signature is `void(grpc::Status)`. */ template > - auto finish(CompletionToken&& token = detail::DefaultCompletionTokenT{}) + auto finish(CompletionToken&& token = CompletionToken{}) { return detail::async_initiate_sender_implementation( this->grpc_context(), detail::ClientFinishWritableStreamSenderInitiation{}, @@ -715,8 +713,7 @@ class ClientRPCServerStreamingBase * error details. */ template > - auto start(StubT& stub, const RequestT& request, - CompletionToken&& token = detail::DefaultCompletionTokenT{}) + auto start(StubT& stub, const RequestT& request, CompletionToken&& token = CompletionToken{}) { return detail::async_initiate_sender_implementation( this->grpc_context(), @@ -736,7 +733,7 @@ class ClientRPCServerStreamingBase * stream has failed (or been cancelled). */ template > - auto read(ResponseT& response, CompletionToken&& token = detail::DefaultCompletionTokenT{}) + auto read(ResponseT& response, CompletionToken&& token = CompletionToken{}) { return detail::async_initiate_sender_implementation( this->grpc_context(), detail::ClientReadSenderInitiation{*this, response}, @@ -772,7 +769,7 @@ class ClientRPCServerStreamingBase * completion signature is `void(grpc::Status)`. */ template > - auto finish(CompletionToken&& token = detail::DefaultCompletionTokenT{}) + auto finish(CompletionToken&& token = CompletionToken{}) { return detail::async_initiate_sender_implementation( this->grpc_context(), detail::ClientFinishServerStreamingSenderInitation{}, @@ -873,7 +870,7 @@ class ClientRPCBidiStreamingBase, Executor> * `void(bool)`. `true` indicates that the metadata was read. If it is `false`, then the call is dead. */ template > - auto read_initial_metadata(CompletionToken&& token = detail::DefaultCompletionTokenT{}) + auto read_initial_metadata(CompletionToken&& token = CompletionToken{}) { return detail::async_initiate_sender_implementation( this->grpc_context(), detail::ClientReadInitialMetadataWritableStreamSenderInitiation{}, @@ -894,7 +891,7 @@ class ClientRPCBidiStreamingBase, Executor> * stream has failed (or been cancelled). */ template > - auto read(ResponseT& response, CompletionToken&& token = detail::DefaultCompletionTokenT{}) + auto read(ResponseT& response, CompletionToken&& token = CompletionToken{}) { return detail::async_initiate_sender_implementation( this->grpc_context(), detail::ClientReadSenderInitiation{*this, response}, @@ -915,8 +912,7 @@ class ClientRPCBidiStreamingBase, Executor> * channel, etc). */ template > - auto write(const RequestT& request, grpc::WriteOptions options, - CompletionToken&& token = detail::DefaultCompletionTokenT{}) + auto write(const RequestT& request, grpc::WriteOptions options, CompletionToken&& token = CompletionToken{}) { return detail::async_initiate_sender_implementation( this->grpc_context(), detail::ClientWriteSenderInitiation{request, options}, @@ -927,7 +923,7 @@ class ClientRPCBidiStreamingBase, Executor> * @brief Send a message to the server (default WriteOptions) */ template > - auto write(const RequestT& request, CompletionToken&& token = detail::DefaultCompletionTokenT{}) + auto write(const RequestT& request, CompletionToken&& token = CompletionToken{}) { return write(request, grpc::WriteOptions{}, static_cast(token)); } @@ -949,7 +945,7 @@ class ClientRPCBidiStreamingBase, Executor> * wire because the call is already dead (i.e., canceled, deadline expired, other side dropped the channel, etc). */ template > - auto writes_done(CompletionToken&& token = detail::DefaultCompletionTokenT{}) + auto writes_done(CompletionToken&& token = CompletionToken{}) { return detail::async_initiate_sender_implementation( this->grpc_context(), detail::ClientWritesDoneSenderInitiation{}, @@ -985,7 +981,7 @@ class ClientRPCBidiStreamingBase, Executor> * completion signature is `void(grpc::Status)`. */ template > - auto finish(CompletionToken&& token = detail::DefaultCompletionTokenT{}) + auto finish(CompletionToken&& token = CompletionToken{}) { return detail::async_initiate_sender_implementation( this->grpc_context(), detail::ClientFinishWritableStreamSenderInitiation{}, @@ -1096,7 +1092,7 @@ class ClientRPC * error details. */ template > - auto start(StubT& stub, CompletionToken&& token = detail::DefaultCompletionTokenT{}) + auto start(StubT& stub, CompletionToken&& token = CompletionToken{}) { return detail::async_initiate_sender_implementation( this->grpc_context(), @@ -1158,8 +1154,7 @@ class ClientRPC * error details. */ template > - auto start(const std::string& method, grpc::GenericStub& stub, - CompletionToken&& token = detail::DefaultCompletionTokenT{}) + auto start(const std::string& method, grpc::GenericStub& stub, CompletionToken&& token = CompletionToken{}) { return detail::async_initiate_sender_implementation( this->grpc_context(), diff --git a/src/agrpc/detail/grpc_context_implementation.hpp b/src/agrpc/detail/grpc_context_implementation.hpp index 097b529e..f75be6d2 100644 --- a/src/agrpc/detail/grpc_context_implementation.hpp +++ b/src/agrpc/detail/grpc_context_implementation.hpp @@ -99,8 +99,7 @@ struct DoOneResult : CompletionQueueEventResult static DoOneResult from(CompletionQueueEventResult handled_event, bool processed_local_work) noexcept { - return {{static_cast(handled_event.flags_ | - (processed_local_work ? DoOneResult::PROCESSED_LOCAL_WORK : uint32_t{}))}}; + return {{handled_event.flags_ | (processed_local_work ? DoOneResult::PROCESSED_LOCAL_WORK : uint32_t{})}}; } explicit operator bool() const noexcept { return processed_local_work() || handled_event(); } diff --git a/src/agrpc/detail/register_rpc_handler_asio_base.hpp b/src/agrpc/detail/register_rpc_handler_asio_base.hpp index 4c285bc1..34c4d5a1 100644 --- a/src/agrpc/detail/register_rpc_handler_asio_base.hpp +++ b/src/agrpc/detail/register_rpc_handler_asio_base.hpp @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include @@ -104,7 +104,7 @@ struct RegisterRPCHandlerInitiator .release(); } - detail::GetServerRPCServiceT& service_; + detail::ServerRPCServiceT& service_; }; template diff --git a/src/agrpc/detail/register_rpc_handler_base.hpp b/src/agrpc/detail/register_rpc_handler_base.hpp index 811bd5ac..82ab62cb 100644 --- a/src/agrpc/detail/register_rpc_handler_base.hpp +++ b/src/agrpc/detail/register_rpc_handler_base.hpp @@ -45,7 +45,7 @@ class RegisterRPCHandlerOperationComplete template struct RegisterRPCHandlerOperationBase { - using Service = detail::GetServerRPCServiceT; + using Service = detail::ServerRPCServiceT; using ServerRPCExecutor = typename ServerRPC::executor_type; RegisterRPCHandlerOperationBase(const ServerRPCExecutor& executor, Service& service, RPCHandler&& rpc_handler) diff --git a/src/agrpc/detail/register_sender_rpc_handler.hpp b/src/agrpc/detail/register_sender_rpc_handler.hpp index 5a5fdb29..e48de6e7 100644 --- a/src/agrpc/detail/register_sender_rpc_handler.hpp +++ b/src/agrpc/detail/register_sender_rpc_handler.hpp @@ -20,9 +20,9 @@ #include #include #include -#include #include #include +#include #include #include @@ -51,7 +51,7 @@ template class [[nodiscard]] RPCHandlerSender : public detail::SenderOf { private: - using Service = detail::GetServerRPCServiceT; + using Service = detail::ServerRPCServiceT; public: RPCHandlerSender(agrpc::GrpcContext& grpc_context, Service& service, RPCHandler&& rpc_handler) @@ -155,7 +155,7 @@ void create_and_start_rpc_handler_operation( template struct RPCHandlerOperation { - using Service = detail::GetServerRPCServiceT; + using Service = detail::ServerRPCServiceT; using Traits = typename ServerRPC::Traits; using Starter = detail::ServerRPCStarterT; using RPCHandlerInvokeResult = detail::RPCHandlerInvokeResultT; @@ -263,9 +263,7 @@ struct RPCHandlerOperation detail::InplaceWithFunction{}, [&] { - return initial_request() - .start(rpc_, operation.service(), agrpc::use_sender) - .connect(StartReceiver{*this}); + return starter().start(rpc_, operation.service(), agrpc::use_sender).connect(StartReceiver{*this}); }) { base().increment_ref_count(); @@ -299,7 +297,7 @@ struct RPCHandlerOperation detail::InplaceWithFunction{}, [&] { - return exec::connect(initial_request().invoke(rpc_handler(), rpc_), FinishReceiver{*this}); + return exec::connect(starter().invoke(rpc_handler(), rpc_), FinishReceiver{*this}); }); return {}; } @@ -326,7 +324,7 @@ struct RPCHandlerOperation auto& rpc_handler() noexcept { return base().rpc_handler(); } - auto& initial_request() noexcept { return impl1_.second(); } + auto& starter() noexcept { return impl1_.second(); } auto& operation_state() noexcept { return impl2_.first(); } diff --git a/src/agrpc/detail/server_rpc_context_base.hpp b/src/agrpc/detail/server_rpc_context_base.hpp index 4d54752d..8d8e9a01 100644 --- a/src/agrpc/detail/server_rpc_context_base.hpp +++ b/src/agrpc/detail/server_rpc_context_base.hpp @@ -128,7 +128,7 @@ struct ServerRPCContextBaseAccess }; template -using GetServerRPCServiceT = decltype(detail::ServerRPCContextBaseAccess::service(std::declval())); +using ServerRPCServiceT = decltype(detail::ServerRPCContextBaseAccess::service(std::declval())); } AGRPC_NAMESPACE_END diff --git a/src/agrpc/detail/rpc_request.hpp b/src/agrpc/detail/server_rpc_starter.hpp similarity index 56% rename from src/agrpc/detail/rpc_request.hpp rename to src/agrpc/detail/server_rpc_starter.hpp index 290ff08f..8ff721fd 100644 --- a/src/agrpc/detail/rpc_request.hpp +++ b/src/agrpc/detail/server_rpc_starter.hpp @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef AGRPC_DETAIL_RPC_REQUEST_HPP -#define AGRPC_DETAIL_RPC_REQUEST_HPP +#ifndef AGRPC_DETAIL_SERVER_RPC_STARTER_HPP +#define AGRPC_DETAIL_SERVER_RPC_STARTER_HPP -#include #include +#include #include @@ -32,10 +32,15 @@ constexpr bool has_initial_request(agrpc::ServerRPCType type) noexcept template struct ServerRPCStarter { - template - auto start(RPC& rpc, Service& service, CompletionToken&& token) + template + auto start(agrpc::ServerRPC& rpc, Service& service, CompletionToken&& token) { - return detail::start(rpc, service, request_, static_cast(token)); + using Responder = std::remove_reference_t; + return detail::async_initiate_sender_implementation( + RPCExecutorBaseAccess::grpc_context(rpc), + detail::ServerRequestSenderInitiation{service, request_}, + detail::ServerRequestSenderImplementation{rpc}, + static_cast(token)); } template @@ -50,10 +55,15 @@ struct ServerRPCStarter template struct ServerRPCStarter { - template - auto start(RPC& rpc, Service& service, CompletionToken&& token) + template + auto start(agrpc::ServerRPC& rpc, Service& service, CompletionToken&& token) { - return detail::start(rpc, service, static_cast(token)); + using Responder = std::remove_reference_t; + return detail::async_initiate_sender_implementation( + RPCExecutorBaseAccess::grpc_context(rpc), + detail::ServerRequestSenderInitiation{service}, + detail::ServerRequestSenderImplementation{rpc}, + static_cast(token)); } template @@ -74,4 +84,4 @@ using RPCHandlerInvokeResultT = AGRPC_NAMESPACE_END -#endif // AGRPC_DETAIL_RPC_REQUEST_HPP +#endif // AGRPC_DETAIL_SERVER_RPC_STARTER_HPP diff --git a/src/agrpc/detail/server_rpc_with_request.hpp b/src/agrpc/detail/server_rpc_with_request.hpp index 3e0470a6..94b7a0ca 100644 --- a/src/agrpc/detail/server_rpc_with_request.hpp +++ b/src/agrpc/detail/server_rpc_with_request.hpp @@ -15,8 +15,8 @@ #ifndef AGRPC_DETAIL_SERVER_RPC_WITH_REQUEST_HPP #define AGRPC_DETAIL_SERVER_RPC_WITH_REQUEST_HPP -#include #include +#include AGRPC_NAMESPACE_BEGIN() diff --git a/src/agrpc/detail/start_server_rpc.hpp b/src/agrpc/detail/start_server_rpc.hpp deleted file mode 100644 index d4aaeec9..00000000 --- a/src/agrpc/detail/start_server_rpc.hpp +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2024 Dennis Hezel -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef AGRPC_DETAIL_START_SERVER_RPC_HPP -#define AGRPC_DETAIL_START_SERVER_RPC_HPP - -#include -#include -#include - -#include - -AGRPC_NAMESPACE_BEGIN() - -namespace detail -{ -template > -auto start(agrpc::ServerRPC& rpc, Service& service, - typename agrpc::ServerRPC::Request& request, - CompletionToken&& token = detail::DefaultCompletionTokenT{}) -{ - using Responder = std::remove_reference_t; - return detail::async_initiate_sender_implementation( - RPCExecutorBaseAccess::grpc_context(rpc), - detail::ServerRequestSenderInitiation{service, request}, - detail::ServerRequestSenderImplementation{rpc}, - static_cast(token)); -} - -template > -auto start(agrpc::ServerRPC& rpc, Service& service, - CompletionToken&& token = detail::DefaultCompletionTokenT{}) -{ - using Responder = std::remove_reference_t; - return detail::async_initiate_sender_implementation( - RPCExecutorBaseAccess::grpc_context(rpc), - detail::ServerRequestSenderInitiation{service}, - detail::ServerRequestSenderImplementation{rpc}, - static_cast(token)); -} - -template > -auto start(agrpc::ServerRPC& rpc, grpc::AsyncGenericService& service, - CompletionToken&& token = detail::DefaultCompletionTokenT{}) -{ - return detail::async_initiate_sender_implementation( - RPCExecutorBaseAccess::grpc_context(rpc), - detail::ServerRequestSenderInitiation{service}, - detail::ServerRequestSenderImplementation{rpc}, - static_cast(token)); -} -} - -AGRPC_NAMESPACE_END - -#endif // AGRPC_DETAIL_START_SERVER_RPC_HPP diff --git a/src/agrpc/read.hpp b/src/agrpc/read.hpp index af2e73c6..d93fb252 100644 --- a/src/agrpc/read.hpp +++ b/src/agrpc/read.hpp @@ -40,7 +40,7 @@ struct ReadFn class CompletionToken = detail::DefaultCompletionTokenT> decltype(auto) operator()(agrpc::ServerRPC& rpc, typename agrpc::ServerRPC::Request& req, - CompletionToken&& token = detail::DefaultCompletionTokenT{}) const + CompletionToken&& token = CompletionToken{}) const noexcept(noexcept(rpc.read(req, static_cast(token)))) { return rpc.read(req, static_cast(token)); @@ -56,7 +56,7 @@ struct ReadFn template > decltype(auto) operator()(agrpc::ClientRPC& rpc, typename agrpc::ClientRPC::Response& response, - CompletionToken&& token = detail::DefaultCompletionTokenT{}) const + CompletionToken&& token = CompletionToken{}) const noexcept(noexcept(rpc.read(response, static_cast(token)))) { return rpc.read(response, static_cast(token)); diff --git a/src/agrpc/register_awaitable_rpc_handler.hpp b/src/agrpc/register_awaitable_rpc_handler.hpp index 5718fc0b..088c82e1 100644 --- a/src/agrpc/register_awaitable_rpc_handler.hpp +++ b/src/agrpc/register_awaitable_rpc_handler.hpp @@ -56,10 +56,11 @@ AGRPC_NAMESPACE_BEGIN() * * @since 2.7.0 */ -template +template > auto register_awaitable_rpc_handler(const typename ServerRPC::executor_type& executor, - detail::GetServerRPCServiceT& service, RPCHandler rpc_handler, - CompletionToken&& token) + detail::ServerRPCServiceT& service, RPCHandler rpc_handler, + CompletionToken&& token = CompletionToken{}) { return asio::async_initiate( detail::RegisterAwaitableRPCHandlerInitiator{service}, token, executor, @@ -72,7 +73,7 @@ auto register_awaitable_rpc_handler(const typename ServerRPC::executor_type& exe * @since 2.7.0 */ template -auto register_awaitable_rpc_handler(agrpc::GrpcContext& grpc_context, detail::GetServerRPCServiceT& service, +auto register_awaitable_rpc_handler(agrpc::GrpcContext& grpc_context, detail::ServerRPCServiceT& service, RPCHandler&& rpc_handler, CompletionToken&& token) { return agrpc::register_awaitable_rpc_handler(grpc_context.get_executor(), service, diff --git a/src/agrpc/register_callback_rpc_handler.hpp b/src/agrpc/register_callback_rpc_handler.hpp index 88c8661b..a8e01035 100644 --- a/src/agrpc/register_callback_rpc_handler.hpp +++ b/src/agrpc/register_callback_rpc_handler.hpp @@ -48,10 +48,11 @@ AGRPC_NAMESPACE_BEGIN() * * @since 2.8.0 */ -template +template > auto register_callback_rpc_handler(const typename ServerRPC::executor_type& executor, - detail::GetServerRPCServiceT& service, RPCHandler rpc_handler, - CompletionToken&& token) + detail::ServerRPCServiceT& service, RPCHandler rpc_handler, + CompletionToken&& token = CompletionToken{}) { return asio::async_initiate( detail::RegisterCallbackRPCHandlerInitiator{service}, token, executor, @@ -64,7 +65,7 @@ auto register_callback_rpc_handler(const typename ServerRPC::executor_type& exec * @since 2.8.0 */ template -auto register_callback_rpc_handler(agrpc::GrpcContext& grpc_context, detail::GetServerRPCServiceT& service, +auto register_callback_rpc_handler(agrpc::GrpcContext& grpc_context, detail::ServerRPCServiceT& service, RPCHandler&& rpc_handler, CompletionToken&& token) { return agrpc::register_callback_rpc_handler(grpc_context.get_executor(), service, diff --git a/src/agrpc/register_sender_rpc_handler.hpp b/src/agrpc/register_sender_rpc_handler.hpp index 5717fa08..d5ae65ce 100644 --- a/src/agrpc/register_sender_rpc_handler.hpp +++ b/src/agrpc/register_sender_rpc_handler.hpp @@ -45,7 +45,7 @@ AGRPC_NAMESPACE_BEGIN() */ template [[nodiscard]] detail::RPCHandlerSender register_sender_rpc_handler( - agrpc::GrpcContext& grpc_context, detail::GetServerRPCServiceT& service, RPCHandler rpc_handler) + agrpc::GrpcContext& grpc_context, detail::ServerRPCServiceT& service, RPCHandler rpc_handler) { using Starter = detail::ServerRPCStarterT; using RPCHandlerInvokeResult = detail::RPCHandlerInvokeResultT; diff --git a/src/agrpc/register_yield_rpc_handler.hpp b/src/agrpc/register_yield_rpc_handler.hpp index b746ea8d..5bfaf10f 100644 --- a/src/agrpc/register_yield_rpc_handler.hpp +++ b/src/agrpc/register_yield_rpc_handler.hpp @@ -50,10 +50,11 @@ AGRPC_NAMESPACE_BEGIN() * * @since 2.7.0 */ -template +template > auto register_yield_rpc_handler(const typename ServerRPC::executor_type& executor, - detail::GetServerRPCServiceT& service, RPCHandler rpc_handler, - CompletionToken&& token) + detail::ServerRPCServiceT& service, RPCHandler rpc_handler, + CompletionToken&& token = CompletionToken{}) { return asio::async_initiate( detail::RegisterYieldRPCHandlerInitiator{service}, token, executor, @@ -66,7 +67,7 @@ auto register_yield_rpc_handler(const typename ServerRPC::executor_type& executo * @since 2.7.0 */ template -auto register_yield_rpc_handler(agrpc::GrpcContext& grpc_context, detail::GetServerRPCServiceT& service, +auto register_yield_rpc_handler(agrpc::GrpcContext& grpc_context, detail::ServerRPCServiceT& service, RPCHandler&& rpc_handler, CompletionToken&& token) { return agrpc::register_yield_rpc_handler(grpc_context.get_executor(), service, diff --git a/src/agrpc/server_rpc.hpp b/src/agrpc/server_rpc.hpp index 7fef79ff..fc012ed7 100644 --- a/src/agrpc/server_rpc.hpp +++ b/src/agrpc/server_rpc.hpp @@ -163,8 +163,7 @@ class ServerRPC * channel, etc). */ template > - auto finish(const ResponseT& response, const grpc::Status& status, - CompletionToken&& token = detail::DefaultCompletionTokenT{}) + auto finish(const ResponseT& response, const grpc::Status& status, CompletionToken&& token = CompletionToken{}) { return detail::async_initiate_sender_implementation( this->grpc_context(), detail::ServerFinishWithMessageInitation{response, status}, @@ -194,8 +193,7 @@ class ServerRPC * channel, etc). */ template > - auto finish_with_error(const grpc::Status& status, - CompletionToken&& token = detail::DefaultCompletionTokenT{}) + auto finish_with_error(const grpc::Status& status, CompletionToken&& token = CompletionToken{}) { return detail::async_initiate_sender_implementation( this->grpc_context(), detail::ServerFinishWithErrorSenderInitation{status}, @@ -335,7 +333,7 @@ class ServerRPC * failed (or been cancelled). */ template > - auto read(RequestT& req, CompletionToken&& token = detail::DefaultCompletionTokenT{}) + auto read(RequestT& req, CompletionToken&& token = CompletionToken{}) { return detail::async_initiate_sender_implementation( this->grpc_context(), detail::ServerReadSenderInitiation{*this, req}, @@ -368,8 +366,7 @@ class ServerRPC * channel, etc). */ template > - auto finish(const ResponseT& response, const grpc::Status& status, - CompletionToken&& token = detail::DefaultCompletionTokenT{}) + auto finish(const ResponseT& response, const grpc::Status& status, CompletionToken&& token = CompletionToken{}) { return detail::async_initiate_sender_implementation( this->grpc_context(), detail::ServerFinishWithMessageInitation{response, status}, @@ -398,8 +395,7 @@ class ServerRPC * channel, etc). */ template > - auto finish_with_error(const grpc::Status& status, - CompletionToken&& token = detail::DefaultCompletionTokenT{}) + auto finish_with_error(const grpc::Status& status, CompletionToken&& token = CompletionToken{}) { return detail::async_initiate_sender_implementation( this->grpc_context(), detail::ServerFinishWithErrorSenderInitation{status}, @@ -541,8 +537,7 @@ class ServerRPC * channel, etc). */ template > - auto write(const ResponseT& response, grpc::WriteOptions options, - CompletionToken&& token = detail::DefaultCompletionTokenT{}) + auto write(const ResponseT& response, grpc::WriteOptions options, CompletionToken&& token = CompletionToken{}) { return detail::async_initiate_sender_implementation( this->grpc_context(), detail::ServerWriteSenderInitiation{*this, response, options}, @@ -553,7 +548,7 @@ class ServerRPC * @brief Send a message to the client (default WriteOptions) */ template > - auto write(const ResponseT& response, CompletionToken&& token = detail::DefaultCompletionTokenT{}) + auto write(const ResponseT& response, CompletionToken&& token = CompletionToken{}) { return write(response, {}, static_cast(token)); } @@ -585,7 +580,7 @@ class ServerRPC */ template > auto write_and_finish(const ResponseT& response, grpc::WriteOptions options, const grpc::Status& status, - CompletionToken&& token = detail::DefaultCompletionTokenT{}) + CompletionToken&& token = CompletionToken{}) { return detail::async_initiate_sender_implementation( this->grpc_context(), detail::ServerWriteAndFinishSenderInitation{response, status, options}, @@ -597,7 +592,7 @@ class ServerRPC */ template > auto write_and_finish(const ResponseT& response, const grpc::Status& status, - CompletionToken&& token = detail::DefaultCompletionTokenT{}) + CompletionToken&& token = CompletionToken{}) { return write_and_finish(response, {}, status, static_cast(static_cast(token))); @@ -622,7 +617,7 @@ class ServerRPC * channel, etc). */ template > - auto finish(const grpc::Status& status, CompletionToken&& token = detail::DefaultCompletionTokenT{}) + auto finish(const grpc::Status& status, CompletionToken&& token = CompletionToken{}) { return detail::async_initiate_sender_implementation( this->grpc_context(), detail::ServerFinishSenderInitation{status}, @@ -676,7 +671,7 @@ class ServerRPCBidiStreamingBase, TraitsT, Execu * messages, either because the other side has called WritesDone() or the stream has failed (or been cancelled). */ template > - auto read(RequestT& req, CompletionToken&& token = detail::DefaultCompletionTokenT{}) + auto read(RequestT& req, CompletionToken&& token = CompletionToken{}) { return detail::async_initiate_sender_implementation( this->grpc_context(), detail::ServerReadSenderInitiation{*this, req}, @@ -698,8 +693,7 @@ class ServerRPCBidiStreamingBase, TraitsT, Execu * channel, etc). */ template > - auto write(const ResponseT& response, grpc::WriteOptions options, - CompletionToken&& token = detail::DefaultCompletionTokenT{}) + auto write(const ResponseT& response, grpc::WriteOptions options, CompletionToken&& token = CompletionToken{}) { return detail::async_initiate_sender_implementation( this->grpc_context(), detail::ServerWriteSenderInitiation{*this, response, options}, @@ -710,7 +704,7 @@ class ServerRPCBidiStreamingBase, TraitsT, Execu * @brief Send a message to the client (default WriteOptions) */ template > - auto write(const ResponseT& response, CompletionToken&& token = detail::DefaultCompletionTokenT{}) + auto write(const ResponseT& response, CompletionToken&& token = CompletionToken{}) { return write(response, {}, static_cast(token)); } @@ -742,7 +736,7 @@ class ServerRPCBidiStreamingBase, TraitsT, Execu */ template > auto write_and_finish(const ResponseT& response, grpc::WriteOptions options, const grpc::Status& status, - CompletionToken&& token = detail::DefaultCompletionTokenT{}) + CompletionToken&& token = CompletionToken{}) { return detail::async_initiate_sender_implementation( this->grpc_context(), detail::ServerWriteAndFinishSenderInitation{response, status, options}, @@ -754,7 +748,7 @@ class ServerRPCBidiStreamingBase, TraitsT, Execu */ template > auto write_and_finish(const ResponseT& response, const grpc::Status& status, - CompletionToken&& token = detail::DefaultCompletionTokenT{}) + CompletionToken&& token = CompletionToken{}) { return write_and_finish(response, {}, status, static_cast(token)); } @@ -786,7 +780,7 @@ class ServerRPCBidiStreamingBase, TraitsT, Execu * channel, etc). */ template > - auto finish(const grpc::Status& status, CompletionToken&& token = detail::DefaultCompletionTokenT{}) + auto finish(const grpc::Status& status, CompletionToken&& token = CompletionToken{}) { return detail::async_initiate_sender_implementation( this->grpc_context(), detail::ServerFinishSenderInitation{status}, diff --git a/src/agrpc/waiter.hpp b/src/agrpc/waiter.hpp index 37c5977d..e99062f7 100644 --- a/src/agrpc/waiter.hpp +++ b/src/agrpc/waiter.hpp @@ -144,7 +144,7 @@ class Waiter * All. Upon cancellation, the initiated operation continues to run. */ template > - auto wait(CompletionToken&& token = detail::DefaultCompletionTokenT{}) + auto wait(CompletionToken&& token = CompletionToken{}) { return wait_impl(static_cast(token)); }