Tue 31 December 2024

☃️ Sane C++ December 24

SC

Welcome to the update post for December 2024!
This month has been mostly spent improving SC::AsyncStreams library with Async Transform Streams!

SC::AsyncStreams

Most of the work has been focused on shaping the SC::AsyncStreams library.

Async streams got their own folder and the AsyncPipeline API has been improved so that it accept transform streams.
Transform streams are used to concurrently modify data read from a source, before it's being written to one or multiple destinations. The sample use case has been compression through ZLIB library.
In order to keep Sane C++ Libraries free of build time dependencies, zlib is dynamically loaded on all major operating systems. A nice trick has been figuring out that the .NET CLR on Windows ships zlib hidden in the clrcompression.dll, avoiding the need to deploy it.

C/C++ compression tip: Avoid deploying zlib binary with your executable, it's already included in the OS. macOS ▶️ libz.dylib Linux ▶️ libz.so.1 (on normal distros) Windows ▶️ clrcompression.dll (.NET CLR) exports: - deflate - deflateEnd - inflate - inflateEnd - deflateInit2_ - inflateInit2_ Enjoy!😏

— Stefano Cristiano (@pagghiu.bsky.social) December 17, 2024 at 10:14 PM

It seems that the fixed pool initial design constraint, that forbids any dynamic allocation inside Async Streams is still working. Some more work will need to be carried on to really prove if it works on a significant number of use cases!

Two Videos have been recorded while implementing the most significant portions of SC::AsyncTransformStream

Detailed List of commits:

SC::Async

SC::Async gets its usual set of monthly minimal improvements. The most significant one is change in API when using thread pools, so that they can be set once and re-used over multiple start of the same request.

Detailed List of commits:

SC::Foundation

SC::AsyncFoundation gets a few new classes to represent read-only and read/write strings without needing to include the entire SC::String library.

Refactoring

Changes in SC::AsyncFoundation have been carried on to reduce header bloat and inter-dependencies between libraries. More specifically both File and Socket library got this treatment, so that Socket doesn't depend on SC::String library at all anymore, and SC::File now has a StringView-free header (FileDescriptor.h) that can be included without bringing any StringView dependency

Minor changes