4

libmill - Go-style concurrency in C

 2 years ago
source link: http://libmill.org/index.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

libmill

libmill.png

Go-style concurrency in C

Libmill is a library that introduces Go-style concurrency to C.

It can execute up to 20 million coroutines and 50 million context switches per second.

Go C go foo(arg1, arg2, arg3) go(foo(arg1, arg2, arg3)); ch := make(chan int) chan ch = chmake(int, 0); ch := make(chan int, 1000) chan ch = chmake(int, 1000); ch <- 42 chs(ch, int, 42); i := <- ch int i = chr(ch, int); close(ch) chdone(ch, int, 0); <garbage collector> chclose(ch); select {
case ch <- 42:
foo()
case i := <- ch:
bar(i)
default:
baz()
} choose {
out(ch, int, 42):
foo();
in(ch, int, i):
bar(i);
otherwise:
baz();
end
}

If you would prefer the same functionality with C-idiomatic API check libdill.

Libmill is licensed under MIT/X11 license.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK