Update some inaccuracies in markdown files
This commit is contained in:
15
design.md
15
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)
|
- **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
|
- **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
|
- **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<Server>`
|
||||||
- **Safe shutdown mechanism** with async-signal-safe shutdown() method
|
- **Safe shutdown mechanism** with async-signal-safe shutdown() method
|
||||||
- **Connection ownership management** with automatic cleanup on server destruction
|
- **Connection ownership management** with automatic cleanup on server destruction
|
||||||
- **Pluggable protocol handlers** via ConnectionHandler interface
|
- **Pluggable protocol handlers** via ConnectionHandler interface
|
||||||
@@ -383,18 +383,7 @@ auto server = Server::create(config, handler);
|
|||||||
|
|
||||||
#### Connection Creation (Server-Only)
|
#### Connection Creation (Server-Only)
|
||||||
|
|
||||||
```cpp
|
Only Server can create connections (using private constructor via friend access)
|
||||||
// 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<Connection>(...); // ERROR: private constructor
|
|
||||||
```
|
|
||||||
|
|
||||||
### ConnectionHandler Implementation Patterns
|
### ConnectionHandler Implementation Patterns
|
||||||
|
|
||||||
|
|||||||
4
style.md
4
style.md
@@ -317,12 +317,12 @@ Arena(Arena &&source) noexcept;
|
|||||||
- **Friend-based factories** for access control when constructor should be private
|
- **Friend-based factories** for access control when constructor should be private
|
||||||
- **Ownership guidelines:**
|
- **Ownership guidelines:**
|
||||||
- **unique_ptr** for exclusive ownership (most common case)
|
- **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
|
- **Factory methods return appropriate smart pointer type** based on ownership needs
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
// Shared ownership - multiple components need concurrent access
|
// Shared ownership - multiple components need concurrent access
|
||||||
auto server = Server::create(config, handler); // Returns shared_ptr
|
auto server = Server::create(config, handler); // Returns Ref<Server>
|
||||||
|
|
||||||
// Exclusive ownership - single owner, transfer via move
|
// Exclusive ownership - single owner, transfer via move
|
||||||
auto connection = Connection::createForServer(addr, fd, connection_id, handler, server_ref);
|
auto connection = Connection::createForServer(addr, fd, connection_id, handler, server_ref);
|
||||||
|
|||||||
Reference in New Issue
Block a user