Transform synchronous C code into seamless asynchronous execution.
Project details
async-a-sync enables writing C code in a synchronous style while executing it asynchronously. By leveraging a compiler built atop Fil-C, this system allows ordinary blocking-looking function calls that return immediately, integrating seamlessly with various pluggable runtimes. This approach enhances performance without requiring significant changes to existing code structures.
async-a-sync is an innovative compiler and runtime system designed to provide asynchronous functionality in C programming while maintaining a synchronous coding style. Built on top of Fil-C, this project allows developers to write code that appears blocking, yet runs asynchronously under the hood, eliminating the need for complex asynchronous coding patterns.
filc_async_wait_all(tags, count) to manage completion of multiple operations efficiently.runtime=<name>. This repository includes two runtimes; one that sends calls as io_uring requests to the kernel in batches and another that handles calls to a TCP server for demonstration purposes.FILC_ASYNC(io_uring, FILC_OP(pread), FILC_BOUT(buf))
void* read_at(int fd, void* buf, size_t len, unsigned long offset);
// Asynchronous file read requests without blocking
for (int i = 0; i < n; i++)
read_at(fd[i], buf[i], len, 0);
// Addressing completion through first access
for (int i = 0; i < n; i++)
if (count_words(buf[i]) != expect[i])
return 1;
When compiled conventionally, the first example would result in blocking reads. However, with async-a-sync, multiple reads complete roughly 3.5 times faster than traditional approaches.
Explore practical demonstrations such as the wait-all demo, which showcases how to efficiently handle multiple asynchronous reads. Documentation is available in the wiki/ folder, covering troubleshooting, annotations, runtimes, and performance evaluations.
async-a-sync streamlines the asynchronous programming process in C by allowing developers to focus on straightforward coding principles while leveraging powerful asynchronous capabilities underneath. For those looking to enhance their C projects with modern asynchronous practices without sacrificing readability or maintainability, this tool provides a high-level approach to effective coding.
Comments
0Start the conversation
Share the first comment.