Network System 0.1.1
High-performance modular networking library for scalable client-server applications
Loading...
Searching...
No Matches
kcenon::network::protocols::quic::stream_manager Class Reference

Manages QUIC streams within a connection. More...

#include <stream_manager.h>

Collaboration diagram for kcenon::network::protocols::quic::stream_manager:
Collaboration graph

Public Member Functions

 stream_manager (bool is_server, uint64_t initial_max_stream_data=65536)
 Construct a stream manager.
 
 ~stream_manager ()=default
 
 stream_manager (const stream_manager &)=delete
 
auto operator= (const stream_manager &) -> stream_manager &=delete
 
 stream_manager (stream_manager &&)=delete
 
auto operator= (stream_manager &&) -> stream_manager &=delete
 
auto create_bidirectional_stream () -> Result< uint64_t >
 Create a new locally-initiated bidirectional stream.
 
auto create_unidirectional_stream () -> Result< uint64_t >
 Create a new locally-initiated unidirectional stream.
 
auto get_stream (uint64_t stream_id) -> stream *
 Get a stream by ID.
 
auto get_stream (uint64_t stream_id) const -> const stream *
 Get a stream by ID (const version)
 
auto get_or_create_stream (uint64_t stream_id) -> Result< stream * >
 Get or create a stream for a peer-initiated stream ID.
 
auto has_stream (uint64_t stream_id) const -> bool
 Check if a stream exists.
 
auto stream_ids () const -> std::vector< uint64_t >
 Get all active stream IDs.
 
auto stream_count () const -> size_t
 Get number of active streams.
 
void set_peer_max_streams_bidi (uint64_t max)
 Set maximum bidirectional streams peer can initiate.
 
void set_peer_max_streams_uni (uint64_t max)
 Set maximum unidirectional streams peer can initiate.
 
auto local_max_streams_bidi () const noexcept -> uint64_t
 Get our maximum bidirectional streams (advertised to peer)
 
auto local_max_streams_uni () const noexcept -> uint64_t
 Get our maximum unidirectional streams (advertised to peer)
 
void set_local_max_streams_bidi (uint64_t max)
 Set our maximum bidirectional streams (advertised to peer)
 
void set_local_max_streams_uni (uint64_t max)
 Set our maximum unidirectional streams (advertised to peer)
 
auto peer_max_streams_bidi () const noexcept -> uint64_t
 Get peer's maximum bidirectional streams (limits our creation)
 
auto peer_max_streams_uni () const noexcept -> uint64_t
 Get peer's maximum unidirectional streams (limits our creation)
 
auto streams_with_pending_data () -> std::vector< stream * >
 Get streams with pending data to send.
 
auto streams_needing_flow_control_update () -> std::vector< stream * >
 Get streams that need MAX_STREAM_DATA updates.
 
void for_each_stream (const std::function< void(stream &)> &callback)
 Iterate over all streams.
 
void for_each_stream (const std::function< void(const stream &)> &callback) const
 Iterate over all streams (const version)
 
auto remove_closed_streams () -> size_t
 Remove closed/terminal streams.
 
void close_all_streams (uint64_t error_code)
 Close all streams with an error code.
 
void reset ()
 Reset manager state (for connection close)
 
auto local_bidi_streams_count () const noexcept -> uint64_t
 Get count of locally-initiated bidirectional streams.
 
auto local_uni_streams_count () const noexcept -> uint64_t
 Get count of locally-initiated unidirectional streams.
 
auto peer_bidi_streams_count () const noexcept -> uint64_t
 Get count of peer-initiated bidirectional streams.
 
auto peer_uni_streams_count () const noexcept -> uint64_t
 Get count of peer-initiated unidirectional streams.
 

Private Member Functions

auto validate_stream_id (uint64_t stream_id) const -> VoidResult
 
auto is_local_stream (uint64_t stream_id) const noexcept -> bool
 
auto can_create_local_stream (bool bidirectional) const -> bool
 
auto can_accept_peer_stream (uint64_t stream_id) const -> bool
 

Private Attributes

bool is_server_
 
uint64_t initial_max_stream_data_
 
uint64_t next_local_bidi_id_
 
uint64_t next_local_uni_id_
 
uint64_t highest_peer_bidi_id_ {0}
 
uint64_t highest_peer_uni_id_ {0}
 
uint64_t peer_bidi_type_
 
uint64_t peer_uni_type_
 
uint64_t local_max_streams_bidi_ {100}
 
uint64_t local_max_streams_uni_ {100}
 
uint64_t peer_max_streams_bidi_ {0}
 
uint64_t peer_max_streams_uni_ {0}
 
std::shared_mutex streams_mutex_
 
std::map< uint64_t, std::unique_ptr< stream > > streams_
 

Detailed Description

Manages QUIC streams within a connection.

Handles stream creation, lookup, and lifecycle management according to RFC 9000 Sections 2-4. Supports both client and server roles with proper stream ID assignment.

Definition at line 29 of file stream_manager.h.

Constructor & Destructor Documentation

◆ stream_manager() [1/3]

kcenon::network::protocols::quic::stream_manager::stream_manager ( bool is_server,
uint64_t initial_max_stream_data = 65536 )
explicit

Construct a stream manager.

Parameters
is_serverTrue if this is a server-side manager
initial_max_stream_dataInitial flow control limit per stream

Definition at line 10 of file stream_manager.cpp.

11 : is_server_{is_server}
12 , initial_max_stream_data_{initial_max_stream_data}
17{
18}

◆ ~stream_manager()

kcenon::network::protocols::quic::stream_manager::~stream_manager ( )
default

◆ stream_manager() [2/3]

kcenon::network::protocols::quic::stream_manager::stream_manager ( const stream_manager & )
delete

◆ stream_manager() [3/3]

kcenon::network::protocols::quic::stream_manager::stream_manager ( stream_manager && )
delete

Member Function Documentation

◆ can_accept_peer_stream()

auto kcenon::network::protocols::quic::stream_manager::can_accept_peer_stream ( uint64_t stream_id) const -> bool
nodiscardprivate

Definition at line 367 of file stream_manager.cpp.

368{
369 const bool is_bidi = stream_id_type::is_bidirectional(stream_id);
370 const uint64_t stream_seq = stream_id_type::get_sequence(stream_id);
371
372 if (is_bidi) {
373 // Check against our MAX_STREAMS_BIDI
374 return stream_seq < local_max_streams_bidi_;
375 } else {
376 // Check against our MAX_STREAMS_UNI
377 return stream_seq < local_max_streams_uni_;
378 }
379}
constexpr auto is_bidirectional(uint64_t stream_id) noexcept -> bool
Check if stream is bidirectional.
Definition stream.h:60
constexpr auto get_sequence(uint64_t stream_id) noexcept -> uint64_t
Get stream sequence number (stream_id >> 2)
Definition stream.h:84

References kcenon::network::protocols::quic::stream_id_type::get_sequence(), and kcenon::network::protocols::quic::stream_id_type::is_bidirectional().

Here is the call graph for this function:

◆ can_create_local_stream()

auto kcenon::network::protocols::quic::stream_manager::can_create_local_stream ( bool bidirectional) const -> bool
nodiscardprivate

Definition at line 354 of file stream_manager.cpp.

355{
356 if (bidirectional) {
357 // Check against peer's MAX_STREAMS_BIDI
358 const uint64_t current_count = next_local_bidi_id_ / 4;
359 return current_count < peer_max_streams_bidi_;
360 } else {
361 // Check against peer's MAX_STREAMS_UNI
362 const uint64_t current_count = (next_local_uni_id_ - 2) / 4;
363 return current_count < peer_max_streams_uni_;
364 }
365}

◆ close_all_streams()

void kcenon::network::protocols::quic::stream_manager::close_all_streams ( uint64_t error_code)

Close all streams with an error code.

Parameters
error_codeError code to use for reset

Definition at line 296 of file stream_manager.cpp.

297{
298 std::unique_lock lock(streams_mutex_);
299 for (auto& [_, s] : streams_) {
300 if (s->can_send()) {
301 (void)s->reset(error_code);
302 }
303 }
304}
std::map< uint64_t, std::unique_ptr< stream > > streams_

References streams_, and streams_mutex_.

◆ create_bidirectional_stream()

auto kcenon::network::protocols::quic::stream_manager::create_bidirectional_stream ( ) -> Result<uint64_t>
nodiscard

Create a new locally-initiated bidirectional stream.

Returns
Stream ID or error

Definition at line 24 of file stream_manager.cpp.

25{
26 if (!can_create_local_stream(true)) {
28 "Bidirectional stream limit reached",
29 "quic::stream_manager");
30 }
31
32 std::unique_lock lock(streams_mutex_);
33
34 uint64_t stream_id = next_local_bidi_id_;
36
37 auto new_stream = std::make_unique<stream>(stream_id, true, initial_max_stream_data_);
38 streams_[stream_id] = std::move(new_stream);
39
40 return ok(std::move(stream_id));
41}
auto can_create_local_stream(bool bidirectional) const -> bool
@ error
Black hole detected, reset to base.
VoidResult ok()

References kcenon::network::protocols::quic::error, kcenon::network::ok(), and kcenon::network::protocols::quic::stream_error::stream_limit_exceeded.

Here is the call graph for this function:

◆ create_unidirectional_stream()

auto kcenon::network::protocols::quic::stream_manager::create_unidirectional_stream ( ) -> Result<uint64_t>
nodiscard

Create a new locally-initiated unidirectional stream.

Returns
Stream ID or error

Definition at line 43 of file stream_manager.cpp.

44{
45 if (!can_create_local_stream(false)) {
47 "Unidirectional stream limit reached",
48 "quic::stream_manager");
49 }
50
51 std::unique_lock lock(streams_mutex_);
52
53 uint64_t stream_id = next_local_uni_id_;
55
56 auto new_stream = std::make_unique<stream>(stream_id, true, initial_max_stream_data_);
57 streams_[stream_id] = std::move(new_stream);
58
59 return ok(std::move(stream_id));
60}

References kcenon::network::protocols::quic::error, kcenon::network::ok(), and kcenon::network::protocols::quic::stream_error::stream_limit_exceeded.

Here is the call graph for this function:

◆ for_each_stream() [1/2]

void kcenon::network::protocols::quic::stream_manager::for_each_stream ( const std::function< void(const stream &)> & callback) const

Iterate over all streams (const version)

Parameters
callbackFunction to call for each stream

Definition at line 238 of file stream_manager.cpp.

239{
240 std::shared_lock lock(streams_mutex_);
241 for (const auto& [_, s] : streams_) {
242 callback(*s);
243 }
244}

References streams_, and streams_mutex_.

◆ for_each_stream() [2/2]

void kcenon::network::protocols::quic::stream_manager::for_each_stream ( const std::function< void(stream &)> & callback)

Iterate over all streams.

Parameters
callbackFunction to call for each stream

Definition at line 230 of file stream_manager.cpp.

231{
232 std::shared_lock lock(streams_mutex_);
233 for (auto& [_, s] : streams_) {
234 callback(*s);
235 }
236}

References streams_, and streams_mutex_.

◆ get_or_create_stream()

auto kcenon::network::protocols::quic::stream_manager::get_or_create_stream ( uint64_t stream_id) -> Result<stream*>
nodiscard

Get or create a stream for a peer-initiated stream ID.

Parameters
stream_idStream identifier
Returns
Pointer to stream or error

This is used when receiving data for a stream that may not exist yet. Peer-initiated streams are implicitly created when first referenced.

Definition at line 80 of file stream_manager.cpp.

81{
82 // First, try to get existing stream
83 {
84 std::shared_lock lock(streams_mutex_);
85 auto it = streams_.find(stream_id);
86 if (it != streams_.end()) {
87 return ok(it->second.get());
88 }
89 }
90
91 // Validate stream ID
92 auto validation = validate_stream_id(stream_id);
93 if (validation.is_err()) {
94 return error<stream*>(validation.error().code,
95 validation.error().message,
96 "quic::stream_manager");
97 }
98
99 // Check if this is a peer-initiated stream
100 if (is_local_stream(stream_id)) {
102 "Local stream must be explicitly created",
103 "quic::stream_manager");
104 }
105
106 // Check stream limits for peer-initiated stream
107 if (!can_accept_peer_stream(stream_id)) {
109 "Peer stream limit exceeded",
110 "quic::stream_manager");
111 }
112
113 // Create implicit streams as needed (RFC 9000 Section 2.1)
114 // When a stream is created, all lower-numbered streams of the same type
115 // must also be created
116 std::unique_lock lock(streams_mutex_);
117
118 const auto type = stream_id_type::get_type(stream_id);
119 const bool is_bidi = stream_id_type::is_bidirectional(stream_id);
120
121 // Determine the first stream ID of this type we need to create
122 uint64_t first_id = type;
123 if (is_bidi) {
124 if (highest_peer_bidi_id_ > 0 || streams_.count(peer_bidi_type_) > 0) {
125 first_id = highest_peer_bidi_id_ + 4;
126 }
127 } else {
128 if (highest_peer_uni_id_ > 0 || streams_.count(peer_uni_type_) > 0) {
129 first_id = highest_peer_uni_id_ + 4;
130 }
131 }
132
133 // Create all streams up to and including the requested one
134 for (uint64_t id = first_id; id <= stream_id; id += 4) {
135 if (streams_.count(id) == 0) {
136 auto new_stream = std::make_unique<stream>(id, false, initial_max_stream_data_);
137 streams_[id] = std::move(new_stream);
138 }
139 }
140
141 // Update highest peer stream ID
142 if (is_bidi) {
143 if (stream_id > highest_peer_bidi_id_ || highest_peer_bidi_id_ == 0) {
144 highest_peer_bidi_id_ = stream_id;
145 }
146 } else {
147 if (stream_id > highest_peer_uni_id_ || highest_peer_uni_id_ == 0) {
148 highest_peer_uni_id_ = stream_id;
149 }
150 }
151
152 return ok(streams_[stream_id].get());
153}
auto can_accept_peer_stream(uint64_t stream_id) const -> bool
auto is_local_stream(uint64_t stream_id) const noexcept -> bool
auto validate_stream_id(uint64_t stream_id) const -> VoidResult
constexpr auto get_type(uint64_t stream_id) noexcept -> uint64_t
Get stream type bits (0-3)
Definition stream.h:76

References kcenon::network::protocols::quic::error, kcenon::network::protocols::quic::stream_id_type::get_type(), kcenon::network::protocols::quic::stream_id_type::is_bidirectional(), kcenon::network::ok(), kcenon::network::protocols::quic::stream_error::stream_limit_exceeded, and kcenon::network::protocols::quic::stream_error::stream_not_found.

Here is the call graph for this function:

◆ get_stream() [1/2]

auto kcenon::network::protocols::quic::stream_manager::get_stream ( uint64_t stream_id) -> stream*
nodiscard

Get a stream by ID.

Parameters
stream_idStream identifier
Returns
Pointer to stream or nullptr if not found

Definition at line 66 of file stream_manager.cpp.

67{
68 std::shared_lock lock(streams_mutex_);
69 auto it = streams_.find(stream_id);
70 return (it != streams_.end()) ? it->second.get() : nullptr;
71}

◆ get_stream() [2/2]

auto kcenon::network::protocols::quic::stream_manager::get_stream ( uint64_t stream_id) const -> const stream*
nodiscard

Get a stream by ID (const version)

Parameters
stream_idStream identifier
Returns
Pointer to stream or nullptr if not found

Definition at line 73 of file stream_manager.cpp.

74{
75 std::shared_lock lock(streams_mutex_);
76 auto it = streams_.find(stream_id);
77 return (it != streams_.end()) ? it->second.get() : nullptr;
78}

◆ has_stream()

auto kcenon::network::protocols::quic::stream_manager::has_stream ( uint64_t stream_id) const -> bool
nodiscard

Check if a stream exists.

Parameters
stream_idStream identifier

Definition at line 155 of file stream_manager.cpp.

156{
157 std::shared_lock lock(streams_mutex_);
158 return streams_.count(stream_id) > 0;
159}

◆ is_local_stream()

auto kcenon::network::protocols::quic::stream_manager::is_local_stream ( uint64_t stream_id) const -> bool
nodiscardprivatenoexcept

Definition at line 348 of file stream_manager.cpp.

349{
352}
constexpr auto is_server_initiated(uint64_t stream_id) noexcept -> bool
Check if stream is server-initiated.
Definition stream.h:52

References kcenon::network::protocols::quic::stream_id_type::is_server_initiated().

Here is the call graph for this function:

◆ local_bidi_streams_count()

auto kcenon::network::protocols::quic::stream_manager::local_bidi_streams_count ( ) const -> uint64_t
inlinenodiscardnoexcept

Get count of locally-initiated bidirectional streams.

Definition at line 225 of file stream_manager.h.

226 {
227 return next_local_bidi_id_ / 4;
228 }

References next_local_bidi_id_.

◆ local_max_streams_bidi()

auto kcenon::network::protocols::quic::stream_manager::local_max_streams_bidi ( ) const -> uint64_t
inlinenodiscardnoexcept

Get our maximum bidirectional streams (advertised to peer)

Definition at line 128 of file stream_manager.h.

129 {
131 }

References local_max_streams_bidi_.

◆ local_max_streams_uni()

auto kcenon::network::protocols::quic::stream_manager::local_max_streams_uni ( ) const -> uint64_t
inlinenodiscardnoexcept

Get our maximum unidirectional streams (advertised to peer)

Definition at line 136 of file stream_manager.h.

137 {
139 }

References local_max_streams_uni_.

◆ local_uni_streams_count()

auto kcenon::network::protocols::quic::stream_manager::local_uni_streams_count ( ) const -> uint64_t
inlinenodiscardnoexcept

Get count of locally-initiated unidirectional streams.

Definition at line 233 of file stream_manager.h.

234 {
235 return (next_local_uni_id_ - 2) / 4;
236 }

References next_local_uni_id_.

◆ operator=() [1/2]

auto kcenon::network::protocols::quic::stream_manager::operator= ( const stream_manager & ) -> stream_manager &=delete
delete

◆ operator=() [2/2]

auto kcenon::network::protocols::quic::stream_manager::operator= ( stream_manager && ) -> stream_manager &=delete
delete

◆ peer_bidi_streams_count()

auto kcenon::network::protocols::quic::stream_manager::peer_bidi_streams_count ( ) const -> uint64_t
inlinenodiscardnoexcept

Get count of peer-initiated bidirectional streams.

Definition at line 241 of file stream_manager.h.

242 {
243 return (highest_peer_bidi_id_ + 4 - peer_bidi_type_) / 4;
244 }

References highest_peer_bidi_id_, and peer_bidi_type_.

◆ peer_max_streams_bidi()

auto kcenon::network::protocols::quic::stream_manager::peer_max_streams_bidi ( ) const -> uint64_t
inlinenodiscardnoexcept

Get peer's maximum bidirectional streams (limits our creation)

Definition at line 156 of file stream_manager.h.

157 {
159 }

References peer_max_streams_bidi_.

◆ peer_max_streams_uni()

auto kcenon::network::protocols::quic::stream_manager::peer_max_streams_uni ( ) const -> uint64_t
inlinenodiscardnoexcept

Get peer's maximum unidirectional streams (limits our creation)

Definition at line 164 of file stream_manager.h.

165 {
167 }

References peer_max_streams_uni_.

◆ peer_uni_streams_count()

auto kcenon::network::protocols::quic::stream_manager::peer_uni_streams_count ( ) const -> uint64_t
inlinenodiscardnoexcept

Get count of peer-initiated unidirectional streams.

Definition at line 249 of file stream_manager.h.

250 {
251 return (highest_peer_uni_id_ + 4 - peer_uni_type_) / 4;
252 }

References highest_peer_uni_id_, and peer_uni_type_.

◆ remove_closed_streams()

auto kcenon::network::protocols::quic::stream_manager::remove_closed_streams ( ) -> size_t

Remove closed/terminal streams.

Returns
Number of streams removed

Definition at line 250 of file stream_manager.cpp.

251{
252 std::unique_lock lock(streams_mutex_);
253 size_t removed = 0;
254
255 for (auto it = streams_.begin(); it != streams_.end();) {
256 const auto& s = it->second;
257
258 // Check if stream is in terminal state on both sides
259 bool send_terminal = (s->send_state() == send_stream_state::data_recvd ||
260 s->send_state() == send_stream_state::reset_recvd);
261 bool recv_terminal = (s->recv_state() == recv_stream_state::data_read ||
262 s->recv_state() == recv_stream_state::reset_read);
263
264 // For unidirectional streams, only check the relevant side
265 if (s->is_unidirectional()) {
266 if (s->is_local()) {
267 // Local unidirectional: only check send side
268 if (send_terminal) {
269 it = streams_.erase(it);
270 ++removed;
271 continue;
272 }
273 } else {
274 // Peer unidirectional: only check receive side
275 if (recv_terminal) {
276 it = streams_.erase(it);
277 ++removed;
278 continue;
279 }
280 }
281 } else {
282 // Bidirectional: check both sides
283 if (send_terminal && recv_terminal) {
284 it = streams_.erase(it);
285 ++removed;
286 continue;
287 }
288 }
289
290 ++it;
291 }
292
293 return removed;
294}
@ data_read
All data read by application (terminal)
@ reset_read
Reset acknowledged by application (terminal)
@ reset_recvd
Reset acknowledged by peer (terminal)
@ data_recvd
All data acknowledged (terminal)

References kcenon::network::protocols::quic::data_read, kcenon::network::protocols::quic::data_recvd, kcenon::network::protocols::quic::reset_read, and kcenon::network::protocols::quic::reset_recvd.

◆ reset()

◆ set_local_max_streams_bidi()

void kcenon::network::protocols::quic::stream_manager::set_local_max_streams_bidi ( uint64_t max)

Set our maximum bidirectional streams (advertised to peer)

Parameters
maxMaximum stream count

Definition at line 192 of file stream_manager.cpp.

193{
195}

References local_max_streams_bidi_.

Referenced by kcenon::network::protocols::quic::connection::set_local_params().

Here is the caller graph for this function:

◆ set_local_max_streams_uni()

void kcenon::network::protocols::quic::stream_manager::set_local_max_streams_uni ( uint64_t max)

Set our maximum unidirectional streams (advertised to peer)

Parameters
maxMaximum stream count

Definition at line 197 of file stream_manager.cpp.

198{
200}

References local_max_streams_uni_.

Referenced by kcenon::network::protocols::quic::connection::set_local_params().

Here is the caller graph for this function:

◆ set_peer_max_streams_bidi()

void kcenon::network::protocols::quic::stream_manager::set_peer_max_streams_bidi ( uint64_t max)

Set maximum bidirectional streams peer can initiate.

Parameters
maxMaximum stream count

Definition at line 182 of file stream_manager.cpp.

183{
185}

References peer_max_streams_bidi_.

Referenced by kcenon::network::protocols::quic::connection::apply_remote_params().

Here is the caller graph for this function:

◆ set_peer_max_streams_uni()

void kcenon::network::protocols::quic::stream_manager::set_peer_max_streams_uni ( uint64_t max)

Set maximum unidirectional streams peer can initiate.

Parameters
maxMaximum stream count

Definition at line 187 of file stream_manager.cpp.

188{
190}

References peer_max_streams_uni_.

Referenced by kcenon::network::protocols::quic::connection::apply_remote_params().

Here is the caller graph for this function:

◆ stream_count()

auto kcenon::network::protocols::quic::stream_manager::stream_count ( ) const -> size_t
nodiscard

Get number of active streams.

Definition at line 172 of file stream_manager.cpp.

173{
174 std::shared_lock lock(streams_mutex_);
175 return streams_.size();
176}

References streams_, and streams_mutex_.

◆ stream_ids()

auto kcenon::network::protocols::quic::stream_manager::stream_ids ( ) const -> std::vector<uint64_t>
nodiscard

Get all active stream IDs.

Definition at line 161 of file stream_manager.cpp.

162{
163 std::shared_lock lock(streams_mutex_);
164 std::vector<uint64_t> ids;
165 ids.reserve(streams_.size());
166 for (const auto& [id, _] : streams_) {
167 ids.push_back(id);
168 }
169 return ids;
170}

References streams_, and streams_mutex_.

◆ streams_needing_flow_control_update()

auto kcenon::network::protocols::quic::stream_manager::streams_needing_flow_control_update ( ) -> std::vector<stream*>
nodiscard

Get streams that need MAX_STREAM_DATA updates.

Returns
Vector of stream pointers

Definition at line 218 of file stream_manager.cpp.

219{
220 std::shared_lock lock(streams_mutex_);
221 std::vector<stream*> result;
222 for (auto& [_, s] : streams_) {
223 if (s->should_send_max_stream_data()) {
224 result.push_back(s.get());
225 }
226 }
227 return result;
228}

◆ streams_with_pending_data()

auto kcenon::network::protocols::quic::stream_manager::streams_with_pending_data ( ) -> std::vector<stream*>
nodiscard

Get streams with pending data to send.

Returns
Vector of stream pointers

Definition at line 206 of file stream_manager.cpp.

207{
208 std::shared_lock lock(streams_mutex_);
209 std::vector<stream*> result;
210 for (auto& [_, s] : streams_) {
211 if (s->pending_bytes() > 0 || (s->fin_sent() && !s->is_fin_received())) {
212 result.push_back(s.get());
213 }
214 }
215 return result;
216}

Referenced by kcenon::network::protocols::quic::connection::has_pending_data().

Here is the caller graph for this function:

◆ validate_stream_id()

auto kcenon::network::protocols::quic::stream_manager::validate_stream_id ( uint64_t stream_id) const -> VoidResult
nodiscardprivate

Definition at line 322 of file stream_manager.cpp.

323{
324 const auto type = stream_id_type::get_type(stream_id);
325
326 // Check if stream type is valid for the role
327 if (is_local_stream(stream_id)) {
328 // Local stream: check against our limits
329 const bool is_bidi = stream_id_type::is_bidirectional(stream_id);
330 if (is_bidi) {
331 if (stream_id >= next_local_bidi_id_) {
333 "Local bidi stream ID too high",
334 "quic::stream_manager");
335 }
336 } else {
337 if (stream_id >= next_local_uni_id_) {
339 "Local uni stream ID too high",
340 "quic::stream_manager");
341 }
342 }
343 }
344
345 return ok();
346}
VoidResult error_void(int code, const std::string &message, const std::string &source="network_system", const std::string &details="")

References kcenon::network::error_void(), kcenon::network::protocols::quic::stream_id_type::get_type(), kcenon::network::protocols::quic::stream_error::invalid_stream_id, kcenon::network::protocols::quic::stream_id_type::is_bidirectional(), and kcenon::network::ok().

Here is the call graph for this function:

Member Data Documentation

◆ highest_peer_bidi_id_

uint64_t kcenon::network::protocols::quic::stream_manager::highest_peer_bidi_id_ {0}
private

Definition at line 265 of file stream_manager.h.

265{0};

Referenced by peer_bidi_streams_count(), and reset().

◆ highest_peer_uni_id_

uint64_t kcenon::network::protocols::quic::stream_manager::highest_peer_uni_id_ {0}
private

Definition at line 266 of file stream_manager.h.

266{0};

Referenced by peer_uni_streams_count(), and reset().

◆ initial_max_stream_data_

uint64_t kcenon::network::protocols::quic::stream_manager::initial_max_stream_data_
private

Definition at line 256 of file stream_manager.h.

◆ is_server_

bool kcenon::network::protocols::quic::stream_manager::is_server_
private

Definition at line 255 of file stream_manager.h.

Referenced by reset().

◆ local_max_streams_bidi_

uint64_t kcenon::network::protocols::quic::stream_manager::local_max_streams_bidi_ {100}
private

Definition at line 271 of file stream_manager.h.

271{100};

Referenced by local_max_streams_bidi(), and set_local_max_streams_bidi().

◆ local_max_streams_uni_

uint64_t kcenon::network::protocols::quic::stream_manager::local_max_streams_uni_ {100}
private

Definition at line 272 of file stream_manager.h.

272{100};

Referenced by local_max_streams_uni(), and set_local_max_streams_uni().

◆ next_local_bidi_id_

uint64_t kcenon::network::protocols::quic::stream_manager::next_local_bidi_id_
private

Definition at line 261 of file stream_manager.h.

Referenced by local_bidi_streams_count(), and reset().

◆ next_local_uni_id_

uint64_t kcenon::network::protocols::quic::stream_manager::next_local_uni_id_
private

Definition at line 262 of file stream_manager.h.

Referenced by local_uni_streams_count(), and reset().

◆ peer_bidi_type_

uint64_t kcenon::network::protocols::quic::stream_manager::peer_bidi_type_
private

Definition at line 267 of file stream_manager.h.

Referenced by peer_bidi_streams_count().

◆ peer_max_streams_bidi_

uint64_t kcenon::network::protocols::quic::stream_manager::peer_max_streams_bidi_ {0}
private

Definition at line 273 of file stream_manager.h.

273{0};

Referenced by peer_max_streams_bidi(), and set_peer_max_streams_bidi().

◆ peer_max_streams_uni_

uint64_t kcenon::network::protocols::quic::stream_manager::peer_max_streams_uni_ {0}
private

Definition at line 274 of file stream_manager.h.

274{0};

Referenced by peer_max_streams_uni(), and set_peer_max_streams_uni().

◆ peer_uni_type_

uint64_t kcenon::network::protocols::quic::stream_manager::peer_uni_type_
private

Definition at line 268 of file stream_manager.h.

Referenced by peer_uni_streams_count().

◆ streams_

std::map<uint64_t, std::unique_ptr<stream> > kcenon::network::protocols::quic::stream_manager::streams_
private

◆ streams_mutex_

std::shared_mutex kcenon::network::protocols::quic::stream_manager::streams_mutex_
mutableprivate

The documentation for this class was generated from the following files: