Skip to content

Commit

Permalink
protobuf/echo/Echo: Remove ServiceProxyResponseQueue
Browse files Browse the repository at this point in the history
  • Loading branch information
richardapeters committed Oct 25, 2023
1 parent f7c6f44 commit b31c3db
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 141 deletions.
74 changes: 0 additions & 74 deletions protobuf/echo/Echo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,37 +62,6 @@ namespace services
virtual void ServiceDone() = 0;
};

template<class ServiceProxyType>
class ServiceProxyResponseQueue
: public ServiceProxyType
{
public:
struct Request
{
infra::Function<void()> onRequestGranted;
uint32_t requestedSize;
};

using Container = infra::BoundedDeque<Request>;

template<std::size_t Max>
using WithStorage = infra::WithStorage<ServiceProxyResponseQueue, typename Container::template WithMaxSize<Max>>;

template<class... Args>
explicit ServiceProxyResponseQueue(Container& container, Args&&... args);

void RequestSend(infra::Function<void()> onRequestGranted) override;
void RequestSend(infra::Function<void()> onRequestGranted, uint32_t requestedSize) override;

private:
void ProcessSendQueue();

private:
Container& container;

bool responseInProgress{ false };
};

class EchoOnStreams
: public Echo
, public infra::EnableSharedFromThis<EchoOnStreams>
Expand Down Expand Up @@ -139,49 +108,6 @@ namespace services

infra::SharedOptional<MethodDeserializerDummy> deserializerDummy;
};

//// Implementation ////

template<class ServiceProxyType>
template<class... Args>
ServiceProxyResponseQueue<ServiceProxyType>::ServiceProxyResponseQueue(Container& container, Args&&... args)
: ServiceProxyType{ std::forward<Args>(args)... }
, container{ container }
{}

template<class ServiceProxyType>
void ServiceProxyResponseQueue<ServiceProxyType>::RequestSend(infra::Function<void()> onRequestGranted)
{
RequestSend(onRequestGranted, ServiceProxyType::MaxMessageSize());
}

template<class ServiceProxyType>
void ServiceProxyResponseQueue<ServiceProxyType>::RequestSend(infra::Function<void()> onRequestGranted, uint32_t requestedSize)
{
if (container.full())
return;

container.push_back({ onRequestGranted, requestedSize });
ProcessSendQueue();
}

template<class ServiceProxyType>
void ServiceProxyResponseQueue<ServiceProxyType>::ProcessSendQueue()
{
if (!responseInProgress && !container.empty())
{
responseInProgress = true;
ServiceProxyType::RequestSend([this]
{
container.front().onRequestGranted();
container.pop_front();

responseInProgress = false;
ProcessSendQueue();
},
container.front().requestedSize);
}
}
}

#endif
1 change: 0 additions & 1 deletion protobuf/echo/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
66 changes: 0 additions & 66 deletions protobuf/echo/test/TestEchoServiceResponseQueue.cpp

This file was deleted.

0 comments on commit b31c3db

Please sign in to comment.