From 698f0f0785c82960c01c7aabb9c2d90fb1de5e15 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Wed, 1 Jan 2025 23:48:10 -0800 Subject: [PATCH] Remove from SimpleBufferPool --- simulation/halsim_ds_socket/src/main/native/cpp/main.cpp | 4 ++-- .../src/main/native/include/HALSimWSClientConnection.h | 2 +- .../src/main/native/include/HALSimHttpConnection.h | 2 +- simulation/halsim_xrp/src/main/native/cpp/HALSimXRP.cpp | 4 ++-- simulation/halsim_xrp/src/main/native/include/HALSimXRP.h | 2 +- wpinet/src/main/native/include/wpinet/uv/Buffer.h | 7 ++----- wpinet/src/test/native/cpp/uv/UvBufferTest.cpp | 8 ++++---- 7 files changed, 13 insertions(+), 16 deletions(-) diff --git a/simulation/halsim_ds_socket/src/main/native/cpp/main.cpp b/simulation/halsim_ds_socket/src/main/native/cpp/main.cpp index 3686d3affdb..50be8bd5af0 100644 --- a/simulation/halsim_ds_socket/src/main/native/cpp/main.cpp +++ b/simulation/halsim_ds_socket/src/main/native/cpp/main.cpp @@ -47,8 +47,8 @@ struct DataStore { }; } // namespace -static SimpleBufferPool<4>& GetBufferPool() { - static SimpleBufferPool<4> bufferPool; +static SimpleBufferPool& GetBufferPool() { + static SimpleBufferPool bufferPool; return bufferPool; } diff --git a/simulation/halsim_ws_client/src/main/native/include/HALSimWSClientConnection.h b/simulation/halsim_ws_client/src/main/native/include/HALSimWSClientConnection.h index 005813f8d78..783f18d013a 100644 --- a/simulation/halsim_ws_client/src/main/native/include/HALSimWSClientConnection.h +++ b/simulation/halsim_ws_client/src/main/native/include/HALSimWSClientConnection.h @@ -41,7 +41,7 @@ class HALSimWSClientConnection bool m_ws_connected = false; wpi::WebSocket* m_websocket = nullptr; - wpi::uv::SimpleBufferPool<4> m_buffers; + wpi::uv::SimpleBufferPool m_buffers; std::mutex m_buffers_mutex; }; diff --git a/simulation/halsim_ws_server/src/main/native/include/HALSimHttpConnection.h b/simulation/halsim_ws_server/src/main/native/include/HALSimHttpConnection.h index 7073256de64..3889849c4cd 100644 --- a/simulation/halsim_ws_server/src/main/native/include/HALSimHttpConnection.h +++ b/simulation/halsim_ws_server/src/main/native/include/HALSimHttpConnection.h @@ -52,7 +52,7 @@ class HALSimHttpConnection bool m_isWsConnected = false; // these are only valid if the websocket is connected - wpi::uv::SimpleBufferPool<4> m_buffers; + wpi::uv::SimpleBufferPool m_buffers; std::mutex m_buffers_mutex; }; diff --git a/simulation/halsim_xrp/src/main/native/cpp/HALSimXRP.cpp b/simulation/halsim_xrp/src/main/native/cpp/HALSimXRP.cpp index 704e172c828..abebcfb75c2 100644 --- a/simulation/halsim_xrp/src/main/native/cpp/HALSimXRP.cpp +++ b/simulation/halsim_xrp/src/main/native/cpp/HALSimXRP.cpp @@ -137,8 +137,8 @@ void HALSimXRP::OnSimValueChanged(const wpi::json& simData) { } } -uv::SimpleBufferPool<4>& HALSimXRP::GetBufferPool() { - static uv::SimpleBufferPool<4> bufferPool(128); +uv::SimpleBufferPool& HALSimXRP::GetBufferPool() { + static uv::SimpleBufferPool bufferPool(128); return bufferPool; } diff --git a/simulation/halsim_xrp/src/main/native/include/HALSimXRP.h b/simulation/halsim_xrp/src/main/native/include/HALSimXRP.h index ee6d7303897..9dca798d35e 100644 --- a/simulation/halsim_xrp/src/main/native/include/HALSimXRP.h +++ b/simulation/halsim_xrp/src/main/native/include/HALSimXRP.h @@ -63,7 +63,7 @@ class HALSimXRP : public wpilibws::HALSimBaseWebSocketConnection, int m_port; void SendStateToXRP(); - wpi::uv::SimpleBufferPool<4>& GetBufferPool(); + wpi::uv::SimpleBufferPool& GetBufferPool(); std::mutex m_buffer_mutex; struct sockaddr_in m_dest; diff --git a/wpinet/src/main/native/include/wpinet/uv/Buffer.h b/wpinet/src/main/native/include/wpinet/uv/Buffer.h index 01dc881a653..53aea255790 100644 --- a/wpinet/src/main/native/include/wpinet/uv/Buffer.h +++ b/wpinet/src/main/native/include/wpinet/uv/Buffer.h @@ -8,12 +8,10 @@ #include #include -#include #include #include #include - -#include +#include namespace wpi::uv { @@ -108,7 +106,6 @@ class Buffer : public uv_buf_t { * to the heap. * @tparam DEPTH depth of pool */ -template class SimpleBufferPool { public: /** @@ -167,7 +164,7 @@ class SimpleBufferPool { size_t Remaining() const { return m_pool.size(); } private: - SmallVector m_pool; + std::vector m_pool; size_t m_size; // NOLINT }; diff --git a/wpinet/src/test/native/cpp/uv/UvBufferTest.cpp b/wpinet/src/test/native/cpp/uv/UvBufferTest.cpp index f349d513373..4e5690e4d8f 100644 --- a/wpinet/src/test/native/cpp/uv/UvBufferTest.cpp +++ b/wpinet/src/test/native/cpp/uv/UvBufferTest.cpp @@ -9,21 +9,21 @@ namespace wpi::uv { TEST(UvSimpleBufferPoolTest, ConstructDefault) { - SimpleBufferPool<> pool; + SimpleBufferPool pool; auto buf1 = pool.Allocate(); ASSERT_EQ(buf1.len, 4096u); // NOLINT pool.Release({&buf1, 1}); } TEST(UvSimpleBufferPoolTest, ConstructSize) { - SimpleBufferPool<4> pool{8192}; + SimpleBufferPool pool{8192}; auto buf1 = pool.Allocate(); ASSERT_EQ(buf1.len, 8192u); // NOLINT pool.Release({&buf1, 1}); } TEST(UvSimpleBufferPoolTest, ReleaseReuse) { - SimpleBufferPool<4> pool; + SimpleBufferPool pool; auto buf1 = pool.Allocate(); auto buf1copy = buf1; auto origSize = buf1.len; @@ -37,7 +37,7 @@ TEST(UvSimpleBufferPoolTest, ReleaseReuse) { } TEST(UvSimpleBufferPoolTest, ClearRemaining) { - SimpleBufferPool<4> pool; + SimpleBufferPool pool; auto buf1 = pool.Allocate(); pool.Release({&buf1, 1}); ASSERT_EQ(pool.Remaining(), 1u);