Git Product home page Git Product logo

coroutine's Introduction

基于boost::context实现一个简单易用的协程库。

该库有以下特性:

  1. 栈自动回溯。未执行完的协程释放时,会自动回溯栈,令C++对象能正确析构。
  2. 协程生命周期自动管理。无需显式调用destroy,协程未在执行并没有任何地 方持有时,会自动释放协程。
  3. 基于libevent实现同步方式的网络操作接口,使用简单高效

常用组件:

  1. 简单的调度器,轮循方式
  2. 简单的分发器,适用于协程内需要等待接收一个数据的情况

依赖库:

  1. boost::context (-lboost_context)
  2. boost::intrusive_ptr
  3. libevent

待实现:

  1. 栈使用mmap分配,并设置mprotect防止栈溢出
  2. 将所有coroutine用双向链表串起来,并提供遍历输出接口
  3. 支持使用函数对象,这样方便在对象中存储更多的信息,避免要传入多个参数 时的麻烦。 (取消,weak_ptr不能直接获得指针,为使用带来麻烦)
  4. 使用std::function<intptr(coroutine_ptr, intptr)>替换原始函数类型, 以支持函数对象
  5. parse_ip_port: add "*:port" support

coroutine's People

Watchers

James Cloos avatar  avatar hpf avatar liuweiguang avatar

Forkers

plumpmath

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.