Repository navigation
Expand file tree
/
Copy pathquic_flow_internal.hpp
More file actions
49 lines (49 loc) · 2.37 KB
/
Copy pathquic_flow_internal.hpp
File metadata and controls
49 lines (49 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* Copyright (C) 2026 Sebastiano Merlino; SPDX-License-Identifier: LGPL-2.1-or-later */
#if !defined(HTTPSERVER_COMPILATION)
#error "quic_flow_internal.hpp is internal"
#endif
#ifndef SRC_HTTPSERVER_DETAIL_QUIC_FLOW_INTERNAL_HPP_
#define SRC_HTTPSERVER_DETAIL_QUIC_FLOW_INTERNAL_HPP_
#include <algorithm>
#include <array>
#include <vector>
#include <httpserver/detail/quic_flow_control.hpp>
namespace httpserver::detail {
inline std::uint64_t flow_add(std::uint64_t a, std::uint64_t b) { return a + std::min(b, k_quic_max_integer - a); }
struct quic_flow_control::implementation {
struct credit {
std::uint64_t desired = 0, emitted = 0, acknowledged = 0;
explicit credit(std::uint64_t initial = 0);
};
struct record {
std::uint64_t id = 0, received = 0, sent = 0, released = 0, receive_window = 0, send_limit = 0;
std::uint64_t reserved = 0;
credit receive_limit;
std::optional<std::uint64_t> sent_final;
const quic_stream_state* receive_owner = nullptr;
bool reset_settled = false, reset_sent = false, retired = false;
};
quic_stream_ids ids;
std::array<std::uint64_t, 4> receive_windows{}, send_windows{};
std::array<std::uint64_t, 2> send_counts{};
std::array<credit, 2> receive_counts;
credit receive_limit;
std::uint64_t receive_window = 0, send_limit = 0, received = 0, sent = 0, released = 0, reserved = 0;
std::size_t maximum;
server::reservation storage;
std::vector<record> records;
quic_flow_code admission = quic_flow_code::ok;
implementation(quic_endpoint_role role, const quic_transport_parameters& local,
const quic_transport_parameters& peer, std::size_t maximum, server::resource_budget budget);
record* find(std::uint64_t id);
const record* find(std::uint64_t id) const;
record* create(std::uint64_t id);
quic_flow_code record_admission(std::uint64_t id) const;
quic_flow_result receive_admission(const quic_stream_state& stream, std::uint64_t id, std::uint64_t end, record*& value);
quic_flow_result consume(const quic_stream_state& stream, std::uint64_t through);
credit* control(const quic_flow_frame& frame);
void release(record& value, std::uint64_t through, bool stream_credit);
};
quic_flow_result flow_result(quic_stream_result result);
} // namespace httpserver::detail
#endif // SRC_HTTPSERVER_DETAIL_QUIC_FLOW_INTERNAL_HPP_