Commit 7ab1ebec authored by Jakob Otto's avatar Jakob Otto

Add review feedback

parent 289d945b
...@@ -27,6 +27,8 @@ namespace net { ...@@ -27,6 +27,8 @@ namespace net {
class multiplexer; class multiplexer;
class socket_manager; class socket_manager;
template <class Application, class IdType>
class transport_worker;
struct network_socket; struct network_socket;
struct pipe_socket; struct pipe_socket;
......
...@@ -65,7 +65,8 @@ public: ...@@ -65,7 +65,8 @@ public:
template <class Parent> template <class Parent>
error init(Parent& parent) { error init(Parent& parent) {
worker_.init(parent); if (auto err = worker_.init(parent))
return err;
parent.mask_add(operation::read); parent.mask_add(operation::read);
return none; return none;
} }
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
namespace caf { namespace caf {
namespace net { namespace net {
/// implements a worker for the udp_transport policy /// Implements a worker for transport protocols.
template <class Application, class IdType = unit_t> template <class Application, class IdType = unit_t>
class transport_worker { class transport_worker {
public: public:
......
...@@ -54,8 +54,8 @@ public: ...@@ -54,8 +54,8 @@ public:
// -- member functions ------------------------------------------------------- // -- member functions -------------------------------------------------------
template <class Header, class... Ts> template <class... Ts>
void write_packet(const Header& header, span<const byte> payload, void write_packet(span<const byte> header, span<const byte> payload,
Ts&&... xs) { Ts&&... xs) {
object_.write_packet(parent_, header, payload, std::forward<Ts>(xs)...); object_.write_packet(parent_, header, payload, std::forward<Ts>(xs)...);
} }
......
...@@ -37,6 +37,8 @@ struct dummy_socket { ...@@ -37,6 +37,8 @@ struct dummy_socket {
// nop // nop
} }
dummy_socket(const dummy_socket&) = default;
dummy_socket& operator=(const dummy_socket& other) { dummy_socket& operator=(const dummy_socket& other) {
id = other.id; id = other.id;
closed = other.closed; closed = other.closed;
......
...@@ -101,10 +101,8 @@ public: ...@@ -101,10 +101,8 @@ public:
void write_message(Parent& parent, void write_message(Parent& parent,
std::unique_ptr<net::endpoint_manager::message> msg) { std::unique_ptr<net::endpoint_manager::message> msg) {
header_type header{static_cast<uint32_t>(msg->payload.size())}; header_type header{static_cast<uint32_t>(msg->payload.size())};
std::vector<byte> header_buf(sizeof(header_type));
std::vector<byte> payload(msg->payload.begin(), msg->payload.end()); std::vector<byte> payload(msg->payload.begin(), msg->payload.end());
memcpy(header_buf.data(), &header, header_buf.size()); parent.write_packet(as_bytes(make_span(&header, 1)), make_span(payload));
parent.write_packet(make_span(header_buf), make_span(payload));
} }
static expected<std::vector<byte>> serialize(actor_system& sys, static expected<std::vector<byte>> serialize(actor_system& sys,
......
...@@ -122,8 +122,8 @@ public: ...@@ -122,8 +122,8 @@ public:
// nop // nop
} }
template <class Header> void write_packet(span<const byte> header, span<const byte> payload,
void write_packet(Header header, span<const byte> payload, ip_endpoint ep) { ip_endpoint ep) {
auto& buf = res_->packet_buffer; auto& buf = res_->packet_buffer;
buf.insert(buf.begin(), header.begin(), header.end()); buf.insert(buf.begin(), header.begin(), header.end());
buf.insert(buf.begin(), payload.begin(), payload.end()); buf.insert(buf.begin(), payload.begin(), payload.end());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment