Need help with libco?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

6.6K Stars 1.8K Forks Other 88 Commits 109 Opened issues


libco is a coroutine library which is widely used in wechat back-end service. It has been running on tens of thousands of machines since 2013.

Services available


Need anything else?

Contributors list


Libco is a c/c++ coroutine library that is widely used in WeChat services. It has been running on tens of thousands of machines since 2013.

By linking with libco, you can easily transform synchronous back-end service into coroutine service. The coroutine service will provide out-standing concurrency compare to multi-thread approach. With the system hook, You can easily coding in synchronous way but asynchronous executed.

You can also use cocreate/coresume/co_yield interfaces to create asynchronous back-end service. These interface will give you more control of coroutines.

By libco copy-stack mode, you can easily build a back-end service support tens of millions of tcp connection.



libco通过仅有的几个函数接口 cocreate/coresume/coyield 再配合 copoll,可以支持同步或者异步的写法,如线程库一样轻松。同时库里面提供了socket族函数的hook,使得后台逻辑服务几乎不用修改逻辑代码就可以完成异步化改造。

作者: sunnyxu([email protected]), leiffyli([email protected]), [email protected]([email protected]), sarlmolchen([email protected])

PS: 近期将开源PaxosStore,敬请期待。


  • 无需侵入业务逻辑,把多进程、多线程服务改造成协程服务,并发能力得到百倍提升;
  • 支持CGI框架,轻松构建web服务(New);
  • 支持gethostbyname、mysqlclient、ssl等常用第三库(New);
  • 可选的共享栈模式,单机轻松接入千万连接(New);
  • 完善简洁的协程编程接口
    • 类pthread接口设计,通过cocreate、coresume等简单清晰接口即可完成协程的创建与恢复;
    • _thread的协程私有变量、协程间通信的协程信号量cosignal (New);
    • 语言级别的lambda实现,结合协程原地编写并执行后台异步任务 (New);
    • 基于epoll/kqueue实现的小而轻的网络框架,基于时间轮盘实现的高性能定时器;


$ cd /path/to/libco
$ make

or use cmake

$ cd /path/to/libco
$ mkdir build
$ cd build
$ cmake ..
$ make

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.