mirror of
https://github.com/facebookincubator/mvfst.git
synced 2025-07-30 14:43:05 +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
@ -7,6 +7,7 @@
|
||||
|
||||
#include <quic/QuicConstants.h>
|
||||
#include <quic/api/QuicPacketScheduler.h>
|
||||
#include <quic/common/BufAccessor.h>
|
||||
#include <quic/flowcontrol/QuicFlowController.h>
|
||||
#include <cstdint>
|
||||
|
||||
@ -902,8 +903,7 @@ SchedulingResult CloningScheduler::scheduleFramesForPacket(
|
||||
size_t prevSize = 0;
|
||||
if (conn_.transportSettings.dataPathType ==
|
||||
DataPathType::ContinuousMemory) {
|
||||
ScopedBufAccessor scopedBufAccessor(conn_.bufAccessor);
|
||||
prevSize = scopedBufAccessor.buf()->length();
|
||||
prevSize = conn_.bufAccessor->length();
|
||||
}
|
||||
// Reusing the same builder throughout loop bodies will lead to frames
|
||||
// belong to different original packets being written into the same clone
|
||||
@ -968,9 +968,7 @@ SchedulingResult CloningScheduler::scheduleFramesForPacket(
|
||||
// when peer fail to parse them.
|
||||
internalBuilder.reset();
|
||||
CHECK(conn_.bufAccessor && conn_.bufAccessor->ownsBuffer());
|
||||
ScopedBufAccessor scopedBufAccessor(conn_.bufAccessor);
|
||||
auto& buf = scopedBufAccessor.buf();
|
||||
buf->trimEnd(buf->length() - prevSize);
|
||||
conn_.bufAccessor->trimEnd(conn_.bufAccessor->length() - prevSize);
|
||||
}
|
||||
}
|
||||
return SchedulingResult(none, none, 0);
|
||||
|
Reference in New Issue
Block a user