From 1726b77ac59bbea3cfdc3af4c328812b1bf21bb4 Mon Sep 17 00:00:00 2001 From: Thad House Date: Tue, 7 May 2019 20:55:58 -0700 Subject: [PATCH] wpiutil: uv: Remove copy from SimpleBufferPool (#1680) --- simulation/halsim_ds_socket/src/main/native/cpp/main.cpp | 3 ++- wpiutil/src/main/native/include/wpi/uv/Buffer.h | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) 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 12cbf7429e..b14f0f4d23 100644 --- a/simulation/halsim_ds_socket/src/main/native/cpp/main.cpp +++ b/simulation/halsim_ds_socket/src/main/native/cpp/main.cpp @@ -133,7 +133,8 @@ static void SetupUdp(wpi::uv::Loop& loop) { outAddr.sin_port = htons(1150); wpi::SmallVector sendBufs; - wpi::raw_uv_ostream stream{sendBufs, GetBufferPool()}; + wpi::raw_uv_ostream stream{sendBufs, + [] { return GetBufferPool().Allocate(); }}; ds->SetupSendBuffer(stream); udpLocal->Send(outAddr, sendBufs, [](auto bufs, Error err) { diff --git a/wpiutil/src/main/native/include/wpi/uv/Buffer.h b/wpiutil/src/main/native/include/wpi/uv/Buffer.h index b500c0f1d4..6df668c541 100644 --- a/wpiutil/src/main/native/include/wpi/uv/Buffer.h +++ b/wpiutil/src/main/native/include/wpi/uv/Buffer.h @@ -108,6 +108,9 @@ class SimpleBufferPool { */ explicit SimpleBufferPool(size_t size = 4096) : m_size{size} {} + SimpleBufferPool(const SimpleBufferPool& other) = delete; + SimpleBufferPool& operator=(const SimpleBufferPool& other) = delete; + /** * Allocate a buffer. */