🟨 Async I/O (files, sockets, timers, processes, fs events, threads, signals) (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, signals) (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 macOSio_uring on Linuxepoll on Linuxio_uring setup is not available on the system, the library will fallback to epoll.If an operation may require blocking work on a backend, the caller must provide a SC::ThreadPool through the operation-specific API. Backends that can perform the operation natively, such as Linux io_uring file I/O, prefer native async by default. Pass SC::AsyncThreadPoolMode::ForceThreadPool to force using the supplied pool.