Sane Coding Blog Notes on Sane C++ Libraries and practical systems work.

❄️ Sane C++ January 25

Welcome to the update post for January 2025! This month has been mostly spent improving <code>SC::Async</code> library!

SC::Async

SC::Async has been the main focus of the month.

Simplification:

  • Remove one state throughout the system (Teardown)

Consistency:

  • Expose callback to signal when a request is fully stopped after issuing a AsyncRequest::stop().

Features:

  • Exclude specific request from active count (it will not keep the loop alive)
  • Enumerate all (non-internal) active and submitted async requests
  • Interrupt event loop even with active requests
  • Update loop time externally
  • Check request state (free / active / cancelling)

Stability:

  • Fix issues with AsyncWakeUp on io_uring

Timers (AsyncLoopTimeout) improvements:

  • Invoke timers consistently when one of them is being cancelled during another timer's callback.
  • Sort timers by expiration time (first) and insertion order (second)
  • Use Monotonic clock everywhere
  • Unify code on all backends (including io_uring)

Detailed List of commits:

SC::AsyncStreams

Some minimal work as been done to the SC::AsyncStreams library as well.

One video has been recorded Showing how to move the transform stream compression operation on a background thread, using AsyncLoopWork. This video pauses (for now) the series of videos dedicated to SC::AsyncStreams.

Detailed List of commits:

SC::Foundation

SC::Foundation most notable change has been using a different approach in SC::Function.

We're now using a vtable-like approach that allows saving one entire pointer (!!) for each SC::Function instance.

The price to pay is the static initialization (that will require a mutex acquisition) and one more indirection, but it has been considered a good tradeoff.

Detailed List of commits:

SC::Time

The SC::Time library got user defined literals, some conversion between different units and differentiation between monotonic and realtime clocks.

A nasty bug regarding time normalization in SC::Time::HighResolutionCounter has been fixed too!

Detailed List of commits:

Minor changes

And these are some minor changes that don't have enough impact to deserve a dedicated comment.

Detailed List of commits: