Code Monkey home page Code Monkey logo

coroutine's Introduction

NOTE: MacOSX is now 10.14.X, any 32 bit program cannot be compiled and 64 bit C library is altered, so our library is not supported under 10.14.X.

It's an asymmetric coroutine library (like lua).

You can use coroutine_open to open a schedule first, and then create coroutine in that schedule.

You should call coroutine_resume in the thread that you call coroutine_open, and you are Allowed to call it in a coroutine in the same schedule.(We use arch-related jmp_buf structure and setjmp/longjmp to implement this X64 version. We also assume a compiler-related call stack layout. Right now, it's for MacOSX only.)

Coroutines in the same schedule share the stack , so you can create many coroutines without worry about memory. But switching context will copy the stack the coroutine used. Most importantly, you should be careful about local variables in coroutines which are designed to receive some kernal data sent by OS, if it's the case, you are required to malloc a space in heap to receive these kind of data. (or kernal might write all data to the same place, and BOOM! All the data are overlapped because we use shared stack in coroutines)

Read source for detail.

The Only Supported Environment (High Sierra is the last supported version, because it is the last version compatible with 32-bits): MacBook Air: X64 / MacOSX 10.9.5/ LLVM 3.5svn

More Detail: cnblogs in chinese

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.