You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26-4Lines changed: 26 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,15 +2,37 @@
2
2
3
3
Custom coroutines implementation in GNU C.
4
4
5
-
## Supported platforms
5
+
## What is a Coroutine?
6
6
7
-
- Linux x86_64
7
+
<!-- This is almost an exact copy of "What is a Coroutine?" section from ./examples/counter.c, but it's slightly modified to make more since on the front README page of a GitHub Repo -->
8
8
9
-
*More are planned in the future*
9
+
Coroutine is a lightweight user space thread with its own stack that can suspend its execution and switch to another coroutine on demand. Coroutines do not run in parallel but rather cooperatively switch between each other whenever they feel like it.
10
+
11
+
Coroutines are useful in cases when all your program does majority of the time is waiting on IO. So with coroutines you have an opportunity to switch the context and go do something else. It is not useful to split up heavy CPU computations because they all going to be executed on a single thread. Use proper thread for that (pthreads on POSIX).
12
+
13
+
Good uses case for coroutines are usually Network Applications and UI. Anything with a slow Async IO.
10
14
11
-
## Quick Start
15
+
<!-- End of the copy of the section -->
16
+
17
+
See [coroutine.h](./coroutine.h) for more info. See [./examples/counter.c](./examples/counter.c) for a simple usage example in C.
18
+
19
+
To build the example:
12
20
13
21
```console
14
22
$ make
15
23
$ ./build/counter
16
24
```
25
+
26
+
There are actually much more examples in the [./examples/](./examples/) in a variety of languages. To build all of them do:
27
+
28
+
```console
29
+
$ make examples
30
+
```
31
+
32
+
Make sure you have all the corresponding compilers for the languages.
0 commit comments