Closed
Description
The recv_buffer implementation supports multiple mode, and the number of diverging code paths based on the mode has been increasing.
Some refactoring could consolidate these path, helping with the maintainability of the code.
Potential improvements
-
Mark "retired" chunks clearly and/or move them out of the chunk list
- "retired" chunks are the ones that won't be used for any read/write operation anymore and will be freed as soon as they are no longer externally referenced
- currently, retired buffer staying in the list means that "single" and "circular" mode look at the last chunk for read/write while other modes start by looking at the first chunk
-
Always treat the first chunk as circular with limited capacity
- "ReadStart" and "Capacity" are enough to ensure operations won't loop around for modes that don't want it
- This should allow to consolidate most paths in "Read" and "Write" operations
-
Refactor the drain logic
- "Partial drain" and "Full drain" evolved to have different meaning for different buffer modes, making it tricky to modify
-
The preallocated chunk pointer could be moved to the stream
- It is allocated and freed by the stream but stored in the recv_buffer, leading to a confusing deinitialization pattern: the recv_buffer must be accessed after being deinitialized to free the chunk
Metadata
Metadata
Assignees
Type
Projects
Status
Done