An open API service indexing awesome lists of open source software.

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

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