hnes / libaco

A blazing fast and lightweight C asymmetric coroutine library 💎 ⛅🚀⛅🌞
https://libaco.org
Apache License 2.0
3.49k stars 392 forks source link

Question: Does libaco only have the implementation of shared stack mode? #19

Closed lancewz closed 5 years ago

lancewz commented 5 years ago

只有共享栈的实现么?


Does libaco only have the implementation of shared stack mode?

hnes commented 5 years ago

libaco also support standalone-stack coroutine.

As the documentation described, if a shared stack has only one user coroutine, then we could call this coroutine a standalone-stack coroutine.

There is also a demonstration of a standalone-stack coroutine in the test_aco_tutorial_2.c.

I hope this answer is helpful for you :D

lancewz commented 5 years ago

Yes I see. Thank you! Can I build libaco with gcc 4.4.6? The complier report error like this "错误:隐式声明函数‘_Static_assert’".

hnes commented 5 years ago

Since the _Static_assert keyword only been supported in gcc4.6 and newer (AFAIK), you may need to use newer compiler toolchain to build libaco.

But as a hack with older gcc (before gcc4.6), you could try the build command below (since all the _Static_assert check during compiling time in libaco is always true on nearly all common platforms):

$ EXTRA_CFLAGS='-D_Static_assert(...)=' bash make.sh
hnes commented 5 years ago

Thank you very much for your report, @lancewz ;-)

I would like to add such friendly support for older gcc in the next release of libaco.

lancewz commented 5 years ago

I build libaco successfully follow your advice. I want to fork libaco and import the features of Tencent's libco (hook I/O functions and do event process). Thank you very much.

hnes commented 5 years ago

I want to fork libaco and import the features of Tencent's libco (hook I/O functions and do event process).

It is a very cool and nice idea :D

I'm now developing a golang-like & libaco-based C coroutine scheduler and would probably be released in several days. These two projects we are developing have something in common. Looking forward to your excellent project!