Live data from Hacker News

Coroutines in C (2000)

chiark.greenend.org.uk

1–10 of 61 posts

Re: Coroutines in C (2000)

#4
I ran with this idea last year and wrote a proof of concept library that wraps libev using using this concept to allow you to write async C code inline. It's about 250 lines of macro abuse and the resulting code looks pretty funky but it ultimately works. I have a simple echo server example here: https://github.com/jeremycw/zasync/blob/master/echo_server.c

Re: Coroutines in C (2000)

#9

A cool library that implements C coroutines, available for both idiomatic C ( http://libdill.org/ ) and in the same style as Go ( http://libmill.org/ ) with line by line translations

For those wondering how it works, libdill keeps track of context between function calls and does some clever stack modification in assembly.
Post reply on HN