1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-04-18 17:24:03 +03:00
mvfst/quic/api/IoBufQuicBatch.h
Hani Damlaj 00e67c1bf9 mvfst License Header Update
Reviewed By: lnicco

Differential Revision: D33587012

fbshipit-source-id: 972eb440f0156c9c04aa6e8787561b18295c1a97
2022-01-18 13:56:12 -08:00

63 lines
1.6 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/QuicException.h>
#include <quic/api/QuicBatchWriter.h>
#include <quic/client/state/ClientStateMachine.h>
#include <quic/state/QuicTransportStatsCallback.h>
namespace quic {
class IOBufQuicBatch {
public:
enum class FlushType {
FLUSH_TYPE_ALWAYS,
FLUSH_TYPE_ALLOW_THREAD_LOCAL_DELAY,
};
IOBufQuicBatch(
BatchWriterPtr&& batchWriter,
bool threadLocal,
folly::AsyncUDPSocket& sock,
const folly::SocketAddress& peerAddress,
QuicTransportStatsCallback* statsCallback,
QuicClientConnectionState::HappyEyeballsState* happyEyeballsState);
~IOBufQuicBatch() = default;
// returns true if it succeeds and false if the loop should end
bool write(std::unique_ptr<folly::IOBuf>&& buf, size_t encodedSize);
bool flush(
FlushType flushType = FlushType::FLUSH_TYPE_ALLOW_THREAD_LOCAL_DELAY);
FOLLY_ALWAYS_INLINE uint64_t getPktSent() const {
return pktSent_;
}
private:
void reset();
// flushes the internal buffers
bool flushInternal();
/**
* Returns whether or not the errno can be retried later.
*/
bool isRetriableError(int err);
BatchWriterPtr batchWriter_;
bool threadLocal_;
folly::AsyncUDPSocket& sock_;
const folly::SocketAddress& peerAddress_;
QuicTransportStatsCallback* statsCallback_{nullptr};
QuicClientConnectionState::HappyEyeballsState* happyEyeballsState_;
uint64_t pktSent_{0};
};
} // namespace quic