|
Network System 0.1.1
High-performance modular networking library for scalable client-server applications
|
Manages QUIC streams within a connection. More...
#include <stream_manager.h>

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_ |
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.
|
explicit |
Construct a stream manager.
| is_server | True if this is a server-side manager |
| initial_max_stream_data | Initial flow control limit per stream |
Definition at line 10 of file stream_manager.cpp.
|
default |
|
delete |
|
delete |
|
nodiscardprivate |
Definition at line 367 of file stream_manager.cpp.
References kcenon::network::protocols::quic::stream_id_type::get_sequence(), and kcenon::network::protocols::quic::stream_id_type::is_bidirectional().

|
nodiscardprivate |
Definition at line 354 of file stream_manager.cpp.
| void kcenon::network::protocols::quic::stream_manager::close_all_streams | ( | uint64_t | error_code | ) |
Close all streams with an error code.
| error_code | Error code to use for reset |
Definition at line 296 of file stream_manager.cpp.
References streams_, and streams_mutex_.
|
nodiscard |
Create a new locally-initiated bidirectional stream.
Definition at line 24 of file stream_manager.cpp.
References kcenon::network::protocols::quic::error, kcenon::network::ok(), and kcenon::network::protocols::quic::stream_error::stream_limit_exceeded.

|
nodiscard |
Create a new locally-initiated unidirectional stream.
Definition at line 43 of file stream_manager.cpp.
References kcenon::network::protocols::quic::error, kcenon::network::ok(), and kcenon::network::protocols::quic::stream_error::stream_limit_exceeded.

| void kcenon::network::protocols::quic::stream_manager::for_each_stream | ( | const std::function< void(const stream &)> & | callback | ) | const |
Iterate over all streams (const version)
| callback | Function to call for each stream |
Definition at line 238 of file stream_manager.cpp.
References streams_, and streams_mutex_.
| void kcenon::network::protocols::quic::stream_manager::for_each_stream | ( | const std::function< void(stream &)> & | callback | ) |
Iterate over all streams.
| callback | Function to call for each stream |
Definition at line 230 of file stream_manager.cpp.
References streams_, and streams_mutex_.
|
nodiscard |
Get or create a stream for a peer-initiated stream ID.
| stream_id | Stream identifier |
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.
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.

|
nodiscard |
Get a stream by ID.
| stream_id | Stream identifier |
Definition at line 66 of file stream_manager.cpp.
|
nodiscard |
Get a stream by ID (const version)
| stream_id | Stream identifier |
Definition at line 73 of file stream_manager.cpp.
|
nodiscard |
Check if a stream exists.
| stream_id | Stream identifier |
Definition at line 155 of file stream_manager.cpp.
|
nodiscardprivatenoexcept |
Definition at line 348 of file stream_manager.cpp.
References kcenon::network::protocols::quic::stream_id_type::is_server_initiated().

|
inlinenodiscardnoexcept |
Get count of locally-initiated bidirectional streams.
Definition at line 225 of file stream_manager.h.
References next_local_bidi_id_.
|
inlinenodiscardnoexcept |
Get our maximum bidirectional streams (advertised to peer)
Definition at line 128 of file stream_manager.h.
References local_max_streams_bidi_.
|
inlinenodiscardnoexcept |
Get our maximum unidirectional streams (advertised to peer)
Definition at line 136 of file stream_manager.h.
References local_max_streams_uni_.
|
inlinenodiscardnoexcept |
Get count of locally-initiated unidirectional streams.
Definition at line 233 of file stream_manager.h.
References next_local_uni_id_.
|
delete |
|
delete |
|
inlinenodiscardnoexcept |
Get count of peer-initiated bidirectional streams.
Definition at line 241 of file stream_manager.h.
References highest_peer_bidi_id_, and peer_bidi_type_.
|
inlinenodiscardnoexcept |
Get peer's maximum bidirectional streams (limits our creation)
Definition at line 156 of file stream_manager.h.
References peer_max_streams_bidi_.
|
inlinenodiscardnoexcept |
Get peer's maximum unidirectional streams (limits our creation)
Definition at line 164 of file stream_manager.h.
References peer_max_streams_uni_.
|
inlinenodiscardnoexcept |
Get count of peer-initiated unidirectional streams.
Definition at line 249 of file stream_manager.h.
References highest_peer_uni_id_, and peer_uni_type_.
| auto kcenon::network::protocols::quic::stream_manager::remove_closed_streams | ( | ) | -> size_t |
Remove closed/terminal streams.
Definition at line 250 of file stream_manager.cpp.
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.
| void kcenon::network::protocols::quic::stream_manager::reset | ( | ) |
Reset manager state (for connection close)
Definition at line 306 of file stream_manager.cpp.
References kcenon::network::protocols::quic::stream_id_type::client_bidi, kcenon::network::protocols::quic::stream_id_type::client_uni, highest_peer_bidi_id_, highest_peer_uni_id_, is_server_, next_local_bidi_id_, next_local_uni_id_, kcenon::network::protocols::quic::stream_id_type::server_bidi, kcenon::network::protocols::quic::stream_id_type::server_uni, streams_, and streams_mutex_.
| void kcenon::network::protocols::quic::stream_manager::set_local_max_streams_bidi | ( | uint64_t | max | ) |
Set our maximum bidirectional streams (advertised to peer)
| max | Maximum stream count |
Definition at line 192 of file stream_manager.cpp.
References local_max_streams_bidi_.
Referenced by kcenon::network::protocols::quic::connection::set_local_params().

| void kcenon::network::protocols::quic::stream_manager::set_local_max_streams_uni | ( | uint64_t | max | ) |
Set our maximum unidirectional streams (advertised to peer)
| max | Maximum stream count |
Definition at line 197 of file stream_manager.cpp.
References local_max_streams_uni_.
Referenced by kcenon::network::protocols::quic::connection::set_local_params().

| void kcenon::network::protocols::quic::stream_manager::set_peer_max_streams_bidi | ( | uint64_t | max | ) |
Set maximum bidirectional streams peer can initiate.
| max | Maximum stream count |
Definition at line 182 of file stream_manager.cpp.
References peer_max_streams_bidi_.
Referenced by kcenon::network::protocols::quic::connection::apply_remote_params().

| void kcenon::network::protocols::quic::stream_manager::set_peer_max_streams_uni | ( | uint64_t | max | ) |
Set maximum unidirectional streams peer can initiate.
| max | Maximum stream count |
Definition at line 187 of file stream_manager.cpp.
References peer_max_streams_uni_.
Referenced by kcenon::network::protocols::quic::connection::apply_remote_params().

|
nodiscard |
Get number of active streams.
Definition at line 172 of file stream_manager.cpp.
References streams_, and streams_mutex_.
|
nodiscard |
Get all active stream IDs.
Definition at line 161 of file stream_manager.cpp.
References streams_, and streams_mutex_.
|
nodiscard |
Get streams that need MAX_STREAM_DATA updates.
Definition at line 218 of file stream_manager.cpp.
|
nodiscard |
Get streams with pending data to send.
Definition at line 206 of file stream_manager.cpp.
Referenced by kcenon::network::protocols::quic::connection::has_pending_data().

|
nodiscardprivate |
Definition at line 322 of file stream_manager.cpp.
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().

|
private |
Definition at line 265 of file stream_manager.h.
Referenced by peer_bidi_streams_count(), and reset().
|
private |
Definition at line 266 of file stream_manager.h.
Referenced by peer_uni_streams_count(), and reset().
|
private |
Definition at line 256 of file stream_manager.h.
|
private |
Definition at line 255 of file stream_manager.h.
Referenced by reset().
|
private |
Definition at line 271 of file stream_manager.h.
Referenced by local_max_streams_bidi(), and set_local_max_streams_bidi().
|
private |
Definition at line 272 of file stream_manager.h.
Referenced by local_max_streams_uni(), and set_local_max_streams_uni().
|
private |
Definition at line 261 of file stream_manager.h.
Referenced by local_bidi_streams_count(), and reset().
|
private |
Definition at line 262 of file stream_manager.h.
Referenced by local_uni_streams_count(), and reset().
|
private |
Definition at line 267 of file stream_manager.h.
Referenced by peer_bidi_streams_count().
|
private |
Definition at line 273 of file stream_manager.h.
Referenced by peer_max_streams_bidi(), and set_peer_max_streams_bidi().
|
private |
Definition at line 274 of file stream_manager.h.
Referenced by peer_max_streams_uni(), and set_peer_max_streams_uni().
|
private |
Definition at line 268 of file stream_manager.h.
Referenced by peer_uni_streams_count().
|
private |
Definition at line 278 of file stream_manager.h.
Referenced by close_all_streams(), for_each_stream(), for_each_stream(), reset(), stream_count(), and stream_ids().
|
mutableprivate |
Definition at line 277 of file stream_manager.h.
Referenced by close_all_streams(), for_each_stream(), for_each_stream(), reset(), stream_count(), and stream_ids().