SC::AsyncStreams#
Pushing it forward
The SC::Async
library has been extended with the addition of SC::AsyncStreams!
Async Streams are largely inspired by node.js Streams, a very powerful tool to process large amounts of data in parallel.
The basic idea about an async stream is to create a Source / Sink abstraction (also called Readable and Writable) and process small buffers of data at time.
The state machine that coordinates this interaction handles data buffering and more importantly handles also back-pressure, that means:
- Pausing the readable stream when a connected writable stream cannot process data fast enough
- Resuming the readable stream when a connected writable stream is finally able to receive more data
When properly implemented for example an async pipeline can concurrently read from disk, write to a socket while compressing data.
For now only Readable / Writable File and Socket streams have been implemented, but Async Transform Streams (for compression) will be next!
Most notable differences with node.js streams are for now:
- No allocation (designed to work inside user-provided list of buffers)
- No object mode
- Fixed Layout to create data pipelines (
AsyncPipeline
) onData
support only (noreadable
event)
Async Streams
are for now in 🟥 Draft state.
It's also possible that its API will evolve a little bit to be less verbose and there is also lack of nice examples, aside from the tests.It's better waiting for it to become stable before doing anything significant with it.
Some changes and fixes in the
SC::Async
library
have been made necessary to support Async Streams.
This is the list of related commits:
- Async: Add AsyncReadableStream
- Async: Add AsyncWritableStream
- Async: Draft AsyncPipeline and AsyncRequest{Readable | Writable} Stream
- Async: Extend AsyncRequest{Readable | Writable}Stream to Socket Send/Receive
- Async: Make AsyncPipeline and AsyncRequest{Readable | Writable}Stream public
- Async: Make AsyncSocket{Send | Receive} buffer and handle public
- Async: Rename AsyncPipeline::Sink to AsyncPipeline::Pipe
- Async: Reorganize AsyncTest for clarity
- Async: Use offsets only if explicitly set in AsyncFile{Read | Write}
Additional fixes#
Fix fix fix
And just like every update, a bunch of fixes and improvements to all libraries have been committed. Nothing specific stands out this update, but for completeness this is the list of related commits:
- Build: Bypass VMWare hgfs issue setting wrong modified time for new files
- Build: Support linking system libraries in XCode
- Containers: Fix compile errors under latest MSVC
- Documentation: Enable warnings as errors
- Documentation: Update README.md with latest videos
- Foundation: Add equality operator to Function
- Foundation: Add HeapBuffer
- Foundation: Add Span::equals
- Foundation: Add Span::get(int)
- Foundation: Add StrongID
- Hashing: Improve documentation
- Meta: Ignore sync folder and icon files
- Tools: Rebuild bootstrap when make fails