Show HN: Async tasks in 350 lines of C

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • cr_task.h

    Header-only library for asynchronous tasks in C

  • FWIW, I opened a PR that adds Windows support: https://github.com/rkaehn/cr_task.h/pull/2

  • libxev

    libxev is a cross-platform, high-performance event loop that provides abstractions for non-blocking IO, timers, events, and more and works on Linux (io_uring or epoll), macOS (kqueue), and Wasm + WASI. Available as both a Zig and C API.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • zigcoro

    A Zig coroutine library

  • craftos2-lua

    Lua fork for CraftOS-PC 2

  • > Do you have examples of any async code returning values without “objects” or compiler magic?

    Lua coroutines represent a yieldable computation, but given a coroutine object, you can't await it or retrieve a return value from it. The only things you can do with a coroutine are check its status and resume it. So how do asynchronous computations return values in Lua?

    It's simple: don't create an extra coroutine around it. If you're already in a yieldable coroutine, then you can call the yielding function directly. Nested yields will bubble up, and from the caller's perspective you just call a function and it returns a value.

    Doing this from Lua is a bit of compiler/interpreter magic, but some modified Lua interpreters support yieldable C functions that can also perform yieldable calls [0]. This requires some due diligence on the part of the caller, making sure to bubble up yields from the inner function and also pass down resumes until it completes (you need to add a state for "this function call yielded"). But it uses no promises, futures or channels.

    [0]: https://github.com/MCJack123/craftos2-lua/blob/89dcba94c28be... (lua_getctx returns whether you're being resumed from a yield, and expects you to have pushed your own state to the Lua stack if you need any.)

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • libxev: A cross-platform, high-performance event loop

    4 projects | news.ycombinator.com | 17 Apr 2024
  • Epoll: The API that powers the modern internet (2022)

    7 projects | news.ycombinator.com | 11 Jan 2024
  • Show HN: 90s – an async C++23 web server with templating engine

    1 project | news.ycombinator.com | 11 Dec 2023
  • Help running crystal on remote server

    1 project | /r/crystal_programming | 5 Jul 2023
  • Windows DNS with CNAME not resolving

    1 project | /r/sysadmin | 28 May 2023