Li0k / Coro

A coroutine library for c++ only for study

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Coro

A coroutine library for c++ only for study

use ucontext

provide a schedule Coro to handle the coroutine

provide some function

  • create

    int create(const coroutine_func &f);

    create a coroutine and return its id

  • resume

    void resume(int id);

    use id to resume a coroutine you want

  • yield

    void yield();

    to yield a coroutine

  • other

    use marco to change property of Coro and coroutine

    • MAX_STACK_SIZE

      set the max size of coroutine runnning stack

    • DEFAULT_NUM

      set the default num of coroutine

    • CO_NUM_LIMIT

      set the max num of coroutine

otherwise Coro provide a Channel class to transfer some message from main thread to coroutine,but it only a toy

it provide some function

  • pop

    template<typename Type>
    Type &Channel<Type>::pop()
  • push

    template<typename Type>
    void Channel<Type>::push(const Type &v)

some example in test1.cpp and test2.cpp

About

A coroutine library for c++ only for study


Languages

Language:C++ 42.4%Language:CMake 23.6%Language:C 20.8%Language:Makefile 13.2%