Zero-copy ethernet TX: encode directly into prepend_buffer, add info/test skills
This commit is contained in:
@@ -6,17 +6,17 @@
|
||||
#include <span>
|
||||
#include "wire.h"
|
||||
#include "timer_queue.h"
|
||||
#include "net.h"
|
||||
|
||||
struct responder {
|
||||
uint32_t message_id;
|
||||
std::function<void(std::span<const uint8_t>)> send;
|
||||
send_fn send;
|
||||
|
||||
template <typename T>
|
||||
void respond(const T& msg) const {
|
||||
uint8_t buf[1024];
|
||||
span_writer out(buf, sizeof(buf));
|
||||
auto r = encode_response_into(out, message_id, msg);
|
||||
if (r) send({buf, *r});
|
||||
send([&](span_writer& out) {
|
||||
return encode_response_into(out, message_id, msg);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user