More cleanup
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
@@ -101,20 +100,21 @@ private:
|
||||
* Private constructor - use create() factory method instead.
|
||||
*
|
||||
* @param config Server configuration (threads, ports, limits, etc.)
|
||||
* @param handler Protocol handler for processing connection data
|
||||
* @param handler Protocol handler for processing connection data. Must
|
||||
* outlive the server.
|
||||
* @param listen_fds Vector of file descriptors to accept connections on.
|
||||
* Server takes ownership and will close them on
|
||||
* Server takes ownership and will close them on
|
||||
* destruction. Server will set these to non-blocking mode for safe epoll
|
||||
* usage.
|
||||
*/
|
||||
explicit Server(const weaseldb::Config &config, ConnectionHandler &handler,
|
||||
const std::vector<int> &listen_fds);
|
||||
friend Ref<Server> make_ref<Server>(const weaseldb::Config &config,
|
||||
ConnectionHandler &handler,
|
||||
const std::vector<int> &listen_fds);
|
||||
template <typename T, typename... Args>
|
||||
friend Ref<T> make_ref(Args &&...args);
|
||||
|
||||
WeakRef<Server> self_;
|
||||
|
||||
const weaseldb::Config &config_;
|
||||
weaseldb::Config config_;
|
||||
ConnectionHandler &handler_;
|
||||
|
||||
// Connection registry
|
||||
@@ -145,25 +145,15 @@ private:
|
||||
int get_epoll_for_thread(int thread_id) const;
|
||||
|
||||
// Helper for processing connection I/O
|
||||
void process_connection_reads(Ref<Connection> &conn_ptr, int events);
|
||||
void process_connection_writes(Ref<Connection> &conn_ptr, int events);
|
||||
void process_connection_reads(Ref<Connection> &conn, int events);
|
||||
void process_connection_writes(Ref<Connection> &conn, int events);
|
||||
|
||||
void close_connection(Ref<Connection> &conn);
|
||||
|
||||
// Helper for processing a batch of connections with their events
|
||||
void process_connection_batch(int epollfd, std::span<Ref<Connection>> batch,
|
||||
void process_connection_batch(std::span<Ref<Connection>> batch,
|
||||
std::span<const int> events);
|
||||
|
||||
/**
|
||||
* Called internally to return ownership to the server.
|
||||
*
|
||||
* This method is thread-safe and can be called from any thread.
|
||||
* The connection will be re-added to the epoll for continued processing.
|
||||
*
|
||||
* @param connection Unique pointer to the connection being released back
|
||||
*/
|
||||
void receiveConnectionBack(Ref<Connection> connection);
|
||||
|
||||
// Make non-copyable and non-movable
|
||||
Server(const Server &) = delete;
|
||||
Server &operator=(const Server &) = delete;
|
||||
|
||||
Reference in New Issue
Block a user