Parent Issue
Part of #315 (TCP receive std::span callback migration)
Summary
Update messaging components that directly use internal::tcp_socket to consume the new std::span<const uint8_t> receive callback internally, removing one copy/allocation per read while keeping existing public APIs intact.
Background
Today the receive path for messaging over TCP typically looks like:
tcp_socket::do_read() allocates + copies into std::vector<uint8_t>
messaging_session / messaging_client then copies that vector again (e.g., enqueueing)
After #316, step (1) can become span-view based (no vector allocation).
Proposed Solution
1) messaging_session
- Register
tcp_socket with set_receive_callback_view(...)
- Change internal
messaging_session::on_receive(...) to accept std::span<const uint8_t>
- When queueing/retaining data is required, copy from span into a single
std::vector<uint8_t> once
Files:
src/session/messaging_session.cpp
include/kcenon/network/session/messaging_session.h
2) messaging_client
- Register
tcp_socket with set_receive_callback_view(...)
- Change internal
messaging_client::on_receive(...) to accept std::span<const uint8_t>
- Keep existing external
set_receive_callback(std::function<void(const std::vector<uint8_t>&)>) working by copying span into a vector only at the API boundary
Files:
src/core/messaging_client.cpp
include/kcenon/network/core/messaging_client.h
Acceptance Criteria
Test Plan
- Run:
ctest --output-on-failure -R messaging
ctest --output-on-failure (full suite as time permits)
Parent Issue
Part of #315 (TCP receive std::span callback migration)
Summary
Update messaging components that directly use
internal::tcp_socketto consume the newstd::span<const uint8_t>receive callback internally, removing one copy/allocation per read while keeping existing public APIs intact.Background
Today the receive path for messaging over TCP typically looks like:
tcp_socket::do_read()allocates + copies intostd::vector<uint8_t>messaging_session/messaging_clientthen copies that vector again (e.g., enqueueing)After #316, step (1) can become span-view based (no vector allocation).
Proposed Solution
1) messaging_session
tcp_socketwithset_receive_callback_view(...)messaging_session::on_receive(...)to acceptstd::span<const uint8_t>std::vector<uint8_t>onceFiles:
src/session/messaging_session.cppinclude/kcenon/network/session/messaging_session.h2) messaging_client
tcp_socketwithset_receive_callback_view(...)messaging_client::on_receive(...)to acceptstd::span<const uint8_t>set_receive_callback(std::function<void(const std::vector<uint8_t>&)>)working by copying span into a vector only at the API boundaryFiles:
src/core/messaging_client.cppinclude/kcenon/network/core/messaging_client.hAcceptance Criteria
tcp_socketspan callback and performs at most one copy when it must retain datatcp_socketspan callback and keeps public vector-based callback behavior unchangedTest Plan
ctest --output-on-failure -R messagingctest --output-on-failure(full suite as time permits)