1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-08-09 20:42:44 +03:00
Files
mvfst/quic/api/QuicBatchWriterFactory.h
Konstantin Tsoy 94c254716d Move a func to fix mvfst mobile build
Summary: Broke in one of the previous commits.

Reviewed By: hanidamlaj

Differential Revision: D47962468

fbshipit-source-id: 532e9356cb7e1bba2e45ac0a18440a12aed1eb25
2023-08-01 19:31:34 -07:00

71 lines
2.2 KiB
C++

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <quic/api/QuicBatchWriter.h>
#include <quic/api/QuicGsoBatchWriters.h>
namespace quic {
BatchWriterPtr makeGsoBatchWriter(uint32_t batchSize);
BatchWriterPtr makeGsoInPlaceBatchWriter(
uint32_t batchSize,
QuicConnectionStateBase& conn);
BatchWriterPtr makeSendmmsgGsoBatchWriter(uint32_t batchSize);
class BatchWriterFactory {
public:
static BatchWriterPtr makeBatchWriter(
const quic::QuicBatchingMode& batchingMode,
uint32_t batchSize,
bool useThreadLocal,
const std::chrono::microseconds& threadLocalDelay,
DataPathType dataPathType,
QuicConnectionStateBase& conn,
bool gsoSupported);
private:
static BatchWriterPtr makeBatchWriterHelper(
const quic::QuicBatchingMode& batchingMode,
uint32_t batchSize,
DataPathType dataPathType,
QuicConnectionStateBase& conn,
bool gsoSupported) {
switch (batchingMode) {
case quic::QuicBatchingMode::BATCHING_MODE_NONE:
if (useSinglePacketInplaceBatchWriter(batchSize, dataPathType)) {
return BatchWriterPtr(new SinglePacketInplaceBatchWriter(conn));
}
return BatchWriterPtr(new SinglePacketBatchWriter());
case quic::QuicBatchingMode::BATCHING_MODE_GSO: {
if (gsoSupported) {
if (dataPathType == DataPathType::ChainedMemory) {
return makeGsoBatchWriter(batchSize);
}
return makeGsoInPlaceBatchWriter(batchSize, conn);
}
return BatchWriterPtr(new SinglePacketBatchWriter());
}
case quic::QuicBatchingMode::BATCHING_MODE_SENDMMSG:
return BatchWriterPtr(new SendmmsgPacketBatchWriter(batchSize));
case quic::QuicBatchingMode::BATCHING_MODE_SENDMMSG_GSO: {
if (gsoSupported) {
return makeSendmmsgGsoBatchWriter(batchSize);
}
return BatchWriterPtr(new SendmmsgPacketBatchWriter(batchSize));
}
// no default so we can catch missing case at compile time
}
folly::assume_unreachable();
}
};
} // namespace quic