mirror of
https://github.com/facebookincubator/mvfst.git
synced 2025-08-08 09:42:06 +03:00
Less direct Buf access in BufAccessor
Summary: **Context** The `BufAccessor` is used to access a contiguous section of memory. Right now, it works with a `Buf` under the hood. **Overall plan** The plan is to change the `BufAccessor` to use a `uint8_t*` instead. Since we're using section of contiguous memory, there's no need to use a chained buffer abstraction here. This'll move us closer to deprecating the usage `folly::IOBuf`. **What this diff is doing** Most use cases of the `BufAccessor` look like the following: ``` auto buf = bufAccessor.obtain(); // Do something with buf, like calling trimEnd bufAccessor.release(buf) ``` I'm adding APIs to the `BufAccessor` so that there's no need to `obtain()` and `release()` the `Buf`. We'd instead just call an API on the `BufAccessor`, which would call that same API on the underlying `folly::IOBuf`. Later on, we'll change the `BufAccessor` to use a `uint8_t*` under the hood. I'm currently leaving in the `obtain()`, `release()`, and `buf()` APIs because Fizz and the AsyncUDPSocket expect `folly::IOBuf` as inputs in many of their APIs. Once those callsites are migrated off `folly::IOBuf`, we can remove these APIs. Reviewed By: mjoras Differential Revision: D60973166 fbshipit-source-id: 52aa3541d0c4878c7ee8525d70ac280508b61e24
This commit is contained in:
committed by
Facebook GitHub Bot
parent
9216eed3d8
commit
a84708be4b
@@ -350,7 +350,7 @@ TEST_F(QuicBatchWriterTest, InplaceWriterNeedsFlush) {
|
||||
gsoSupported_ = true;
|
||||
uint32_t batchSize = 20;
|
||||
auto bufAccessor =
|
||||
std::make_unique<SimpleBufAccessor>(conn_.udpSendPacketLen * batchSize);
|
||||
std::make_unique<BufAccessor>(conn_.udpSendPacketLen * batchSize);
|
||||
conn_.bufAccessor = bufAccessor.get();
|
||||
auto batchWriter = quic::BatchWriterFactory::makeBatchWriter(
|
||||
quic::QuicBatchingMode::BATCHING_MODE_GSO,
|
||||
@@ -373,7 +373,7 @@ TEST_F(QuicBatchWriterTest, InplaceWriterAppendLimit) {
|
||||
gsoSupported_ = true;
|
||||
uint32_t batchSize = 20;
|
||||
auto bufAccessor =
|
||||
std::make_unique<SimpleBufAccessor>(conn_.udpSendPacketLen * batchSize);
|
||||
std::make_unique<BufAccessor>(conn_.udpSendPacketLen * batchSize);
|
||||
conn_.bufAccessor = bufAccessor.get();
|
||||
auto batchWriter = quic::BatchWriterFactory::makeBatchWriter(
|
||||
quic::QuicBatchingMode::BATCHING_MODE_GSO,
|
||||
@@ -404,7 +404,7 @@ TEST_F(QuicBatchWriterTest, InplaceWriterAppendSmaller) {
|
||||
gsoSupported_ = true;
|
||||
uint32_t batchSize = 20;
|
||||
auto bufAccessor =
|
||||
std::make_unique<SimpleBufAccessor>(conn_.udpSendPacketLen * batchSize);
|
||||
std::make_unique<BufAccessor>(conn_.udpSendPacketLen * batchSize);
|
||||
conn_.bufAccessor = bufAccessor.get();
|
||||
auto batchWriter = quic::BatchWriterFactory::makeBatchWriter(
|
||||
quic::QuicBatchingMode::BATCHING_MODE_GSO,
|
||||
@@ -438,7 +438,7 @@ TEST_F(QuicBatchWriterTest, InplaceWriterWriteAll) {
|
||||
quic::test::MockAsyncUDPSocket sock(qEvb);
|
||||
uint32_t batchSize = 20;
|
||||
auto bufAccessor =
|
||||
std::make_unique<SimpleBufAccessor>(conn_.udpSendPacketLen * batchSize);
|
||||
std::make_unique<BufAccessor>(conn_.udpSendPacketLen * batchSize);
|
||||
conn_.bufAccessor = bufAccessor.get();
|
||||
gsoSupported_ = true;
|
||||
auto batchWriter = quic::BatchWriterFactory::makeBatchWriter(
|
||||
@@ -487,7 +487,7 @@ TEST_F(QuicBatchWriterTest, InplaceWriterWriteOne) {
|
||||
quic::test::MockAsyncUDPSocket sock(qEvb);
|
||||
uint32_t batchSize = 20;
|
||||
auto bufAccessor =
|
||||
std::make_unique<SimpleBufAccessor>(conn_.udpSendPacketLen * batchSize);
|
||||
std::make_unique<BufAccessor>(conn_.udpSendPacketLen * batchSize);
|
||||
conn_.bufAccessor = bufAccessor.get();
|
||||
gsoSupported_ = true;
|
||||
auto batchWriter = quic::BatchWriterFactory::makeBatchWriter(
|
||||
@@ -528,7 +528,7 @@ TEST_F(QuicBatchWriterTest, InplaceWriterLastOneTooBig) {
|
||||
quic::test::MockAsyncUDPSocket sock(qEvb);
|
||||
uint32_t batchSize = 20;
|
||||
auto bufAccessor =
|
||||
std::make_unique<SimpleBufAccessor>(conn_.udpSendPacketLen * batchSize);
|
||||
std::make_unique<BufAccessor>(conn_.udpSendPacketLen * batchSize);
|
||||
conn_.bufAccessor = bufAccessor.get();
|
||||
gsoSupported_ = true;
|
||||
auto batchWriter = quic::BatchWriterFactory::makeBatchWriter(
|
||||
@@ -576,7 +576,7 @@ TEST_F(QuicBatchWriterTest, InplaceWriterBufResidueCheck) {
|
||||
|
||||
uint32_t batchSize = 20;
|
||||
auto bufAccessor =
|
||||
std::make_unique<SimpleBufAccessor>(conn_.udpSendPacketLen * batchSize);
|
||||
std::make_unique<BufAccessor>(conn_.udpSendPacketLen * batchSize);
|
||||
conn_.bufAccessor = bufAccessor.get();
|
||||
conn_.udpSendPacketLen = 1000;
|
||||
auto batchWriter = quic::BatchWriterFactory::makeBatchWriter(
|
||||
@@ -618,8 +618,7 @@ class SinglePacketInplaceBatchWriterTest : public ::testing::Test {
|
||||
: conn_(FizzServerQuicHandshakeContext::Builder().build()) {}
|
||||
|
||||
void SetUp() override {
|
||||
bufAccessor_ =
|
||||
std::make_unique<quic::SimpleBufAccessor>(conn_.udpSendPacketLen);
|
||||
bufAccessor_ = std::make_unique<quic::BufAccessor>(conn_.udpSendPacketLen);
|
||||
conn_.bufAccessor = bufAccessor_.get();
|
||||
}
|
||||
|
||||
@@ -641,7 +640,7 @@ class SinglePacketInplaceBatchWriterTest : public ::testing::Test {
|
||||
}
|
||||
|
||||
protected:
|
||||
std::unique_ptr<quic::SimpleBufAccessor> bufAccessor_;
|
||||
std::unique_ptr<quic::BufAccessor> bufAccessor_;
|
||||
QuicServerConnectionState conn_;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user