Skip to content
/ Coro Public

A coroutine library for c++ only for study

Notifications You must be signed in to change notification settings

Li0k/Coro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published