https://github.com/li0k/coro
A coroutine library for c++ only for study
https://github.com/li0k/coro
coroutine cpp ucontext
Last synced: 9 months ago
JSON representation
A coroutine library for c++ only for study
- Host: GitHub
- URL: https://github.com/li0k/coro
- Owner: Li0k
- Created: 2018-07-21T09:37:36.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-21T10:02:15.000Z (almost 8 years ago)
- Last Synced: 2025-05-14T07:51:12.389Z (about 1 year ago)
- Topics: coroutine, cpp, ucontext
- Language: C++
- Homepage:
- Size: 421 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Coro
A coroutine library for c++ only for study
use ucontext
provide a schedule Coro to handle the coroutine
provide some function
- create
```c++
int create(const coroutine_func &f);
```
create a coroutine and return its id
- resume
```c++
void resume(int id);
```
use id to resume a coroutine you want
- yield
```c++
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
```c++
template
Type &Channel::pop()
```
- push
```c++
template
void Channel::push(const Type &v)
```
some example in test1.cpp and test2.cpp