diff --git a/protobuf/echo/Echo.hpp b/protobuf/echo/Echo.hpp index b077e6299..832b305b3 100644 --- a/protobuf/echo/Echo.hpp +++ b/protobuf/echo/Echo.hpp @@ -62,37 +62,6 @@ namespace services virtual void ServiceDone() = 0; }; - template - class ServiceProxyResponseQueue - : public ServiceProxyType - { - public: - struct Request - { - infra::Function onRequestGranted; - uint32_t requestedSize; - }; - - using Container = infra::BoundedDeque; - - template - using WithStorage = infra::WithStorage>; - - template - explicit ServiceProxyResponseQueue(Container& container, Args&&... args); - - void RequestSend(infra::Function onRequestGranted) override; - void RequestSend(infra::Function onRequestGranted, uint32_t requestedSize) override; - - private: - void ProcessSendQueue(); - - private: - Container& container; - - bool responseInProgress{ false }; - }; - class EchoOnStreams : public Echo , public infra::EnableSharedFromThis @@ -139,49 +108,6 @@ namespace services infra::SharedOptional deserializerDummy; }; - - //// Implementation //// - - template - template - ServiceProxyResponseQueue::ServiceProxyResponseQueue(Container& container, Args&&... args) - : ServiceProxyType{ std::forward(args)... } - , container{ container } - {} - - template - void ServiceProxyResponseQueue::RequestSend(infra::Function onRequestGranted) - { - RequestSend(onRequestGranted, ServiceProxyType::MaxMessageSize()); - } - - template - void ServiceProxyResponseQueue::RequestSend(infra::Function onRequestGranted, uint32_t requestedSize) - { - if (container.full()) - return; - - container.push_back({ onRequestGranted, requestedSize }); - ProcessSendQueue(); - } - - template - void ServiceProxyResponseQueue::ProcessSendQueue() - { - if (!responseInProgress && !container.empty()) - { - responseInProgress = true; - ServiceProxyType::RequestSend([this] - { - container.front().onRequestGranted(); - container.pop_front(); - - responseInProgress = false; - ProcessSendQueue(); - }, - container.front().requestedSize); - } - } } #endif diff --git a/protobuf/echo/test/CMakeLists.txt b/protobuf/echo/test/CMakeLists.txt index 9dd11414e..6fb247752 100644 --- a/protobuf/echo/test/CMakeLists.txt +++ b/protobuf/echo/test/CMakeLists.txt @@ -5,7 +5,6 @@ emil_add_test(protobuf.echo_test) protocol_buffer_echo_cpp(protobuf.echo_test TestMessages.proto) target_sources(protobuf.echo_test PRIVATE - TestEchoServiceResponseQueue.cpp TestProtoMessageReceiver.cpp TestProtoMessageSender.cpp TestServiceForwarder.cpp diff --git a/protobuf/echo/test/TestEchoServiceResponseQueue.cpp b/protobuf/echo/test/TestEchoServiceResponseQueue.cpp deleted file mode 100644 index 93f6e7169..000000000 --- a/protobuf/echo/test/TestEchoServiceResponseQueue.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "infra/util/Function.hpp" -#include "infra/util/test_helper/MockCallback.hpp" -#include "protobuf/echo/Echo.hpp" -#include "protobuf/echo/test_doubles/EchoMock.hpp" -#include "protobuf/echo/test_doubles/ServiceStub.hpp" -#include "gmock/gmock.h" -#include "gtest/gtest.h" - -namespace services -{ - class EchoServiceResponseQueueTest - : public testing::Test - { - public: - testing::StrictMock echo; - testing::StrictMock>::WithStorage<2> serviceProxy{ echo }; - }; - - TEST_F(EchoServiceResponseQueueTest, RequestSendWhileEmptyImmediatelyForwardsRequestToEcho) - { - EXPECT_CALL(echo, RequestSend(testing::Ref(serviceProxy))); - - serviceProxy.RequestSend(infra::emptyFunction); - } - - TEST_F(EchoServiceResponseQueueTest, RequestsNextRequestAfterGrantingAccess) - { - infra::VerifyingFunctionMock request1{}; - infra::VerifyingFunctionMock request2{}; - - EXPECT_CALL(echo, RequestSend(testing::Ref(serviceProxy))).Times(2); - - serviceProxy.RequestSend(request1, 128); - serviceProxy.RequestSend(request2, 50); - - EXPECT_THAT(serviceProxy.CurrentRequestedSize(), testing::Eq(128)); - serviceProxy.GrantSend(); - - EXPECT_THAT(serviceProxy.CurrentRequestedSize(), testing::Eq(50)); - serviceProxy.GrantSend(); - } - - TEST_F(EchoServiceResponseQueueTest, DiscardsRequestWhenQueueFull) - { - infra::VerifyingFunctionMock request1{}; - infra::VerifyingFunctionMock request2{}; - infra::VerifyingFunctionMock request4{}; - - EXPECT_CALL(echo, RequestSend(testing::Ref(serviceProxy))) - .Times(3); - - serviceProxy.RequestSend(request1); - serviceProxy.RequestSend(request2); - - serviceProxy.RequestSend([] - { - FAIL(); - }); - - serviceProxy.GrantSend(); - serviceProxy.GrantSend(); - - serviceProxy.RequestSend(request4); - serviceProxy.GrantSend(); - } -}