Introduction

libcsp is a concurrency library influenced by the CSP model. It’s 10x faster than golang.

Features

  • Multiple cpu cores supported.
  • Stack size is statically analyzed in comple time and can also be set manually.
  • Lock-free channel.
  • Netpoll supported.
  • Timer supported.

Go

go foo(arg1, arg2, arg3)

var wg sync.WaitGroup
wg.Add(2)
go func() { defer wg.Done(); foo(); }()
go func() { defer wg.Done(); bar(); }()
wg.Wait()

runtime.Gosched()

chn := make(chan int, 1 << 6)
num = <-chn
chn <- num

timer := time.AfterFunc(time.Second, foo)
timer.Stop()

Libcsp

async(foo(arg1, arg2, arg3));

sync(foo(); bar());





yield();

chan_t(int) *chn = chan_new(int)(6);
chan_pop(chn, &num);
chan_push(chn, num);

timer_t timer = timer_after(timer_second, foo());
timer_cancel(timer);