From be5a0c6d8e9a32e31b064f179ed5e0a908df3afb Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Fri, 12 Sep 2025 11:31:22 -0400 Subject: [PATCH] Update some inaccuracies in markdown files --- design.md | 15 ++------------- style.md | 4 ++-- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/design.md b/design.md index 39e39e8..1dedd12 100644 --- a/design.md +++ b/design.md @@ -118,7 +118,7 @@ Ultra-fast memory allocator optimized for request/response patterns: - **Configurable epoll instances** to eliminate kernel-level epoll_ctl contention (default: 2, max: io_threads) - **Round-robin thread-to-epoll assignment** distributes I/O threads across epoll instances - **Connection distribution** keeps accepted connections on same epoll, returns via round-robin -- **Factory pattern construction** via `Server::create()` ensures proper shared_ptr semantics +- **Factory pattern construction** via `Server::create()` ensures you can only get a `Ref` - **Safe shutdown mechanism** with async-signal-safe shutdown() method - **Connection ownership management** with automatic cleanup on server destruction - **Pluggable protocol handlers** via ConnectionHandler interface @@ -383,18 +383,7 @@ auto server = Server::create(config, handler); #### Connection Creation (Server-Only) -```cpp -// Only Server can create connections (using private friend method) -class Server { -private: - auto conn = Connection::createForServer(addr, fd, id, handler, weak_from_this()); -}; - -// No public way to create connections - all these fail: -// auto conn = Connection::create(...); // ERROR: no such method -// Connection conn(addr, fd, id, handler, server); // ERROR: private constructor -// auto conn = std::make_unique(...); // ERROR: private constructor -``` +Only Server can create connections (using private constructor via friend access) ### ConnectionHandler Implementation Patterns diff --git a/style.md b/style.md index bddc4f9..6871587 100644 --- a/style.md +++ b/style.md @@ -317,12 +317,12 @@ Arena(Arena &&source) noexcept; - **Friend-based factories** for access control when constructor should be private - **Ownership guidelines:** - **unique_ptr** for exclusive ownership (most common case) - - **shared_ptr** only when multiple owners need concurrent access to same object + - **Ref** only when object logically has multiple owners (`Ref` is our custom std::shared_ptr variant) - **Factory methods return appropriate smart pointer type** based on ownership needs ```cpp // Shared ownership - multiple components need concurrent access -auto server = Server::create(config, handler); // Returns shared_ptr +auto server = Server::create(config, handler); // Returns Ref // Exclusive ownership - single owner, transfer via move auto connection = Connection::createForServer(addr, fd, connection_id, handler, server_ref);