Compare commits

...

2 Commits

Author SHA1 Message Date
7806b64783 writer as unique ptr 2024-11-21 11:38:44 +01:00
253b182c45 move writer 2024-11-21 11:31:47 +01:00
2 changed files with 7 additions and 2 deletions

View File

@ -1,5 +1,6 @@
#include "rpc_server.hpp"
#include "json.hpp"
#include <memory>
#include <netinet/in.h>
#include <sys/socket.h>
#include <unistd.h>
@ -57,8 +58,8 @@ auto slige_rpc::RpcServer<Functor>::listen() -> Res<Unit>
continue;
}
auto req = sliger::json::parse_json(message);
auto writer = BufferedWriter(client);
this->functor(req, writer);
auto writer = std::make_unique<BufferedWriter>(client);
this->functor(req, std::move(writer));
message.clear();
break;
}

View File

@ -63,6 +63,10 @@ public:
: fd(fd)
{
}
BufferedWriter(const BufferedWriter&) = delete;
BufferedWriter operator=(const BufferedWriter&) = delete;
BufferedWriter(BufferedWriter&&) = delete;
BufferedWriter operator=(BufferedWriter&&) = delete;
~BufferedWriter() { close(fd); }
auto flush() -> Res<size_t>;