Minor tidying and cleanup
This commit is contained in:
@@ -7,27 +7,14 @@
|
||||
|
||||
// TODO fix up this whole thing
|
||||
|
||||
std::unique_ptr<Connection>
|
||||
Connection::createForServer(struct sockaddr_storage addr, int fd, int64_t id,
|
||||
size_t epoll_index, ConnectionHandler *handler,
|
||||
std::weak_ptr<Server> server) {
|
||||
// Use unique_ptr constructor with private access (friend function)
|
||||
// We can't use make_unique here because constructor is private
|
||||
return std::unique_ptr<Connection>(
|
||||
new Connection(addr, fd, id, epoll_index, handler, server));
|
||||
}
|
||||
|
||||
Connection::Connection(struct sockaddr_storage addr, int fd, int64_t id,
|
||||
size_t epoll_index, ConnectionHandler *handler,
|
||||
std::weak_ptr<Server> server)
|
||||
Server &server)
|
||||
: fd_(fd), id_(id), epoll_index_(epoll_index), addr_(addr), arena_(),
|
||||
handler_(handler), server_(server) {
|
||||
if (auto server_ptr = server_.lock()) {
|
||||
server_ptr->active_connections_.fetch_add(1, std::memory_order_relaxed);
|
||||
}
|
||||
if (handler_) {
|
||||
handler_->on_connection_established(*this);
|
||||
}
|
||||
handler_(handler), server_(server.weak_from_this()) {
|
||||
server.active_connections_.fetch_add(1, std::memory_order_relaxed);
|
||||
assert(handler_);
|
||||
handler_->on_connection_established(*this);
|
||||
}
|
||||
|
||||
Connection::~Connection() {
|
||||
|
||||
Reference in New Issue
Block a user