Remove release_back_to_server
This commit is contained in:
@@ -26,21 +26,21 @@ public:
|
||||
* Process incoming data from a connection.
|
||||
*
|
||||
* @param data Incoming data buffer (may be partial message)
|
||||
* @param conn_ptr Unique pointer to connection - handler can take ownership
|
||||
* by releasing it
|
||||
* @param conn Connection reference - server retains ownership
|
||||
*
|
||||
* Implementation should:
|
||||
* - Parse incoming data using arena allocator when needed
|
||||
* - Use conn_ptr->append_message() to queue response data to be sent
|
||||
* - Create request-scoped Arena for parsing and response generation
|
||||
* - Parse incoming data using the request arena
|
||||
* - Use conn.append_message() to queue response data to be sent
|
||||
* - Handle partial messages and streaming protocols appropriately
|
||||
* - Can take ownership by calling conn_ptr.release() to pass to other threads
|
||||
* - If ownership is taken, handler must call Server::release_back_to_server()
|
||||
* when done
|
||||
* @note `data` is *not* owned by the connection arena, and its lifetime ends
|
||||
* after the call to on_data_arrived.
|
||||
* - Use conn.get_weak_ref() for async processing if needed
|
||||
*
|
||||
* @note `data` lifetime ends after the call to on_data_arrived.
|
||||
* @note May be called from an arbitrary server thread.
|
||||
* @note Handler can safely access connection concurrently via thread-safe
|
||||
* methods.
|
||||
*/
|
||||
virtual void on_data_arrived(std::string_view /*data*/, Ref<Connection> &) {};
|
||||
virtual void on_data_arrived(std::string_view /*data*/, Connection &) {};
|
||||
|
||||
/**
|
||||
* Called when data has been successfully written to the connection.
|
||||
@@ -50,29 +50,26 @@ public:
|
||||
* - Implementing backpressure for continuous data streams
|
||||
* - Progress monitoring for long-running transfers
|
||||
*
|
||||
* @param conn_ptr Connection that made write progress - handler can take
|
||||
* ownership
|
||||
* @param conn Connection that made write progress - server retains ownership
|
||||
* @note May be called from an arbitrary server thread.
|
||||
* @note Called during writes, not necessarily when buffer becomes empty
|
||||
*/
|
||||
virtual void on_write_progress(Ref<Connection> &) {}
|
||||
virtual void on_write_progress(Connection &) {}
|
||||
|
||||
/**
|
||||
* Called when the connection's outgoing write buffer becomes empty.
|
||||
*
|
||||
* This indicates all queued messages have been successfully written
|
||||
* to the socket. Useful for:
|
||||
* - Resetting arena allocators safely
|
||||
* - Implementing keep-alive connection reuse
|
||||
* - Closing connections after final response
|
||||
* - Relieving backpressure conditions
|
||||
*
|
||||
* @param conn_ptr Connection with empty write buffer - handler can take
|
||||
* ownership
|
||||
* @param conn Connection with empty write buffer - server retains ownership
|
||||
* @note May be called from an arbitrary server thread.
|
||||
* @note Only called on transitions from non-empty → empty buffer
|
||||
*/
|
||||
virtual void on_write_buffer_drained(Ref<Connection> &) {}
|
||||
virtual void on_write_buffer_drained(Connection &) {}
|
||||
|
||||
/**
|
||||
* Called when a new connection is established.
|
||||
@@ -101,11 +98,9 @@ public:
|
||||
*
|
||||
* This hook is called after on_data_arrived, on_write_progress, or
|
||||
* on_write_buffer_drained has been called for each connection in the batch.
|
||||
* The handler can take ownership of the connections by moving the unique_ptr
|
||||
* out of the span. Any connections left in the span will remain owned by the
|
||||
* server.
|
||||
* All connections remain server-owned.
|
||||
*
|
||||
* @param batch A span of unique_ptrs to the connections in the batch.
|
||||
* @param batch A span of connection references in the batch.
|
||||
*/
|
||||
virtual void on_batch_complete(std::span<Ref<Connection>> /*batch*/) {}
|
||||
virtual void on_batch_complete(std::span<Connection *> /*batch*/) {}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user