Home > Enterprise >  How can i implement concurrency in C like we do in go? [closed]
How can i implement concurrency in C like we do in go? [closed]

Time:09-27

I would like to implement go's concurrency in C because I have seen that it increases the [performance] of go. I have not tried anything because I can't understand what to try. How can I do that?

CodePudding user response:

Coroutines are not available in C natively (although they're supported in C starting with C 20), so you're going to rely on external libraries or you'll have to implement something yourself.

Some useful resources: an example by Simon Tatham, another small example, a C library called libaco, an interesting article with an alternative approach.

Another approach could be using an event-loop, that is the same approach used by JavaScript to implement concurrency within a single thread. One of the most used libraries is libuv and here's a small example of using libuv.

  • Related