DeepWiki
I've been feeding the Sane C++ Libraries repo to DeepWiki and I am actually surprised by how good it has understood the overall codebase structure! Some details are wrong and sometimes it analyzes details that are not really worth that much, but it's really amazing how much insight it provides at a glance to someone who is not aware of the internals of the project.
Make sure to check it out at:
https://deepwiki.com/Pagghiu/SaneCppLibraries
Async Sequence
AsyncSequence
allows controlling requests execution order, and it's implemented as a simple linked list queue that can simplify some common use cases.
For example AsyncSequence
can be used to issue an AsyncSocketConnect
request and then a sequence of AsyncSocketSend
or a AsyncSocketReceive
immediately after.
AsyncSequence
avoids the need to start such additional requests in the callback of the previously finished requests.
This is a (not so small) extract of the test suite where AsyncSequence
is being used to queue two writes so that they will happen in the correct order.
Async Cancellations
Lastly Async requests cancellation handling has been consolidated between all backends and it's more precise and consistent.
Some async backends (Windows IOCP
/ Linux io_uring
) post cancellations notification to the kernel queue.
This is now properly handled by stepping the event loop one more time.
The remaining changes try to consistently track multiple edge cases when processing cancellations:
cancelAsync
is called only if an activateAsync has been previously calledteardownAsync
is called only if setupAsync has been previously called
Honestly trying to unify these kind of behaviors between APIs that are so wildly different is really challenging!
Async Improvements
SC::Async
has been receiving some additional fine tuning reducing the size of all AsyncRequest, removing some common fields like eventIndex and event loop pointer.
AsyncFileClose
and AsyncSocketClose
have finally seen their return code moved to completion data and AsyncSocketConnect will stop its watcher in case of errors.
- Async: Add method to create async UDP socket associated with event loop
- Async: Avoid enabling Socket connect watcher on errors (Posix)
- Socket: Add method to check SocketIPAddress validity
- Async: Do not access request after completion unless it has been reactivated
- Async: Allow removing file / socket association with event loop
- Async: Move AsyncFileClose return code to completion data
- Async: Remove useless [[nodiscard]]
- Async: Split AsyncSocketAcceptData out of AsyncSocketAccept
- Async: Declare per-request debug name only when SC_ASYNC_ENABLE_LOG is defined
- Async: Remove pointer to event loop inside async requests
- Async: Store 2 bytes of user flags in AsyncRequest
- Async: Do not store event index per each request
- Async: Migrate code to completion data in AsyncSocketClose