Unify accept and network threads into io threads
This commit is contained in:
@@ -21,12 +21,13 @@ extern std::atomic<int> activeConnections;
|
||||
* Represents a single client connection with efficient memory management.
|
||||
*
|
||||
* Connection ownership model:
|
||||
* - Created by accept thread, transferred to epoll via raw pointer
|
||||
* - Network threads claim ownership by wrapping raw pointer in unique_ptr
|
||||
* - Network thread optionally passes ownership to a thread pipeline
|
||||
* - Created by I/O thread, processed immediately, then transferred to epoll via
|
||||
* raw pointer
|
||||
* - I/O threads claim ownership by wrapping raw pointer in unique_ptr
|
||||
* - I/O thread optionally passes ownership to a thread pipeline
|
||||
* - Owner eventually transfers back to epoll by releasing unique_ptr to raw
|
||||
* pointer
|
||||
* - RAII cleanup happens if network thread doesn't transfer back
|
||||
* - RAII cleanup happens if I/O thread doesn't transfer back
|
||||
*
|
||||
* Arena allocator thread safety:
|
||||
* Each Connection contains its own ArenaAllocator instance that is accessed
|
||||
@@ -68,7 +69,7 @@ struct Connection {
|
||||
* @brief Queue a message to be sent to the client.
|
||||
*
|
||||
* Adds data to the connection's outgoing message queue. The data will be sent
|
||||
* asynchronously by the server's network threads using efficient vectored
|
||||
* asynchronously by the server's I/O threads using efficient vectored
|
||||
* I/O.
|
||||
*
|
||||
* @param s The data to send (string view for zero-copy efficiency)
|
||||
@@ -342,7 +343,7 @@ private:
|
||||
* @return std::unique_ptr<Connection> to the newly created connection
|
||||
*
|
||||
* @note This method is only accessible to the Server class and should be used
|
||||
* exclusively by accept threads when new connections arrive.
|
||||
* exclusively by I/O threads when new connections arrive.
|
||||
*/
|
||||
static std::unique_ptr<Connection>
|
||||
createForServer(struct sockaddr_storage addr, int fd, int64_t id,
|
||||
|
||||
Reference in New Issue
Block a user