🟨 Async I/O (files, sockets, timers, processes, fs events, threads wake-up) (see Async for more details) Async is a multi-platform / event-driven asynchronous I/O library. More...
🟨 Async I/O (files, sockets, timers, processes, fs events, threads wake-up) (see Async for more details) Async is a multi-platform / event-driven asynchronous I/O library.
It exposes async programming model for common IO operations like reading / writing to / from a file or tcp socket.
Synchronous I/O operations could block the current thread of execution for an undefined amount of time, making it difficult to scale an application to a large number of concurrent operations, or to coexist with other even loop, like for example a GUI event loop. Such async programming model uses a common pattern, where the call fills an AsyncRequest with the required data. The AsyncRequest is added to an AsyncEventLoop that will queue the request to some low level OS IO queue. The event loop can then monitor all the requests in a single call to SC::AsyncEventLoop::run, SC::AsyncEventLoop::runOnce or SC::AsyncEventLoop::runNoWait. These three different run methods cover different integration use cases of the event loop inside of an applications.
The kernel Async API used on each operating systems are the following:
IOCP
on Windowskqueue
on macOSepoll
on Linuxio_uring
on Linux (dynamically loading liburing
)liburing
is not available on the system, the library will transparently fallback to epoll.If an async operation is not supported by the OS, the caller can provide a SC::ThreadPool to run it on a thread. See SC::AsyncFileRead / SC::AsyncFileWrite for an example.