Remove release_back_to_server

This commit is contained in:
2025-09-12 19:43:39 -04:00
parent e887906da8
commit e96a493835
10 changed files with 295 additions and 342 deletions

View File

@@ -65,21 +65,19 @@
* at a time
*
* ### Thread Ownership Model:
* 1. **Network Thread**: Claims connection ownership, accesses arena for I/O
* buffers
* 2. **Handler Thread**: Can take ownership via unique_ptr.release(), uses
* arena for request parsing and response generation
* 3. **Background Thread**: Can receive ownership for async processing, uses
* arena for temporary data structures
* 4. **Return Path**: Connection (and its arena) safely returned via
* Server::release_back_to_server()
* 1. **I/O Thread**: Server owns connections, processes socket I/O events
* 2. **Handler Thread**: Receives Connection& reference, creates request-scoped
* arenas for parsing and response generation
* 3. **Pipeline Thread**: Can use WeakRef<Connection> for async processing,
* creates own arenas for temporary data structures
* 4. **Arena Lifecycle**: Request-scoped arenas moved to message queue, freed
* after I/O completion without holding connection mutex
*
* ### Why This Design is Thread-Safe:
* - **Exclusive Access**: Only the current owner thread should access the arena
* - **Transfer Points**: Ownership transfers happen at well-defined
* synchronization points with proper memory barriers.
* - **No Shared State**: Each arena is completely isolated - no shared data
* between different arena instances
* - **Request-Scoped**: Each request gets its own Arena instance for isolation
* - **Move Semantics**: Arenas transferred via move, avoiding shared access
* - **Deferred Cleanup**: Arena destruction deferred to avoid malloc contention
* while holding connection mutex
*
* @warning Do not share Arena instances between threads. Use separate
* instances per thread or per logical unit of work.