TCPStreamPusher: Single class handling multiple connections

This commit is contained in:
2026-03-04 16:51:43 +01:00
parent d2c66edd45
commit 204ae82825
7 changed files with 833 additions and 846 deletions

View File

@@ -22,22 +22,14 @@ TEST_CASE("TCPImageCommTest_2Writers_WithAck", "[TCP]") {
std::vector<uint16_t> image1(x.GetPixelsNum() * nframes);
for (auto &i : image1) i = dist(g1);
std::vector<std::string> addr{
"tcp://127.0.0.1:19001",
"tcp://127.0.0.1:19002"
};
std::string addr = "tcp://127.0.0.1:19001";
std::vector<std::unique_ptr<TCPImagePuller>> puller;
for (int i = 0; i < npullers; i++) {
puller.push_back(std::make_unique<TCPImagePuller>(addr[i], 64 * 1024 * 1024));
puller.push_back(std::make_unique<TCPImagePuller>(addr, 64 * 1024 * 1024));
}
TCPStreamPusher pusher(
addr,
64 * 1024 * 1024,
128 * 1024,
8192
);
TCPStreamPusher pusher(addr,npullers);
std::vector<size_t> received(npullers, 0);
std::vector<size_t> processed(npullers, 0);
@@ -152,22 +144,13 @@ TEST_CASE("TCPImageCommTest_DataFatalAck_PropagatesToPusher", "[TCP]") {
std::vector<uint16_t> image1(x.GetPixelsNum() * nframes);
for (auto &i : image1) i = dist(g1);
std::vector<std::string> addr{
"tcp://127.0.0.1:19011",
"tcp://127.0.0.1:19012"
};
std::string addr = "tcp://127.0.0.1:19003";
std::vector<std::unique_ptr<TCPImagePuller>> puller;
for (int i = 0; i < npullers; i++) {
puller.push_back(std::make_unique<TCPImagePuller>(addr[i], 64 * 1024 * 1024));
}
for (int i = 0; i < npullers; i++)
puller.push_back(std::make_unique<TCPImagePuller>(addr, 64 * 1024 * 1024));
TCPStreamPusher pusher(
addr,
64 * 1024 * 1024,
128 * 1024,
8192
);
TCPStreamPusher pusher(addr,npullers);
std::atomic<bool> sent_fatal{false};
@@ -196,7 +179,7 @@ TEST_CASE("TCPImageCommTest_DataFatalAck_PropagatesToPusher", "[TCP]") {
(void)pusher.SendImage(serialization_buffer.data(), serializer.GetBufferSize(), i);
}
REQUIRE_FALSE(pusher.EndDataCollection(end));
REQUIRE(pusher.EndDataCollection(end));
const auto final_msg = pusher.Finalize();
REQUIRE_THAT(final_msg, Catch::Matchers::ContainsSubstring("quota"));
});
@@ -287,22 +270,13 @@ TEST_CASE("TCPImageCommTest_GetAckProgress_Correct", "[TCP]") {
std::vector<uint16_t> image1(x.GetPixelsNum() * nframes);
for (auto &i : image1) i = dist(g1);
std::vector<std::string> addr{
"tcp://127.0.0.1:19021",
"tcp://127.0.0.1:19022"
};
std::string addr = "tcp://127.0.0.1:19004";
std::vector<std::unique_ptr<TCPImagePuller>> puller;
for (int i = 0; i < npullers; i++) {
puller.push_back(std::make_unique<TCPImagePuller>(addr[i], 64 * 1024 * 1024));
}
for (int i = 0; i < npullers; i++)
puller.push_back(std::make_unique<TCPImagePuller>(addr, 64 * 1024 * 1024));
TCPStreamPusher pusher(
addr,
64 * 1024 * 1024,
128 * 1024,
8192
);
TCPStreamPusher pusher(addr,npullers);
std::thread sender([&] {
std::vector<uint8_t> serialization_buffer(16 * 1024 * 1024);