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
+164-7Lines changed: 164 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,10 +13,167 @@
13
13
14
14
## Introduction
15
15
16
-
This branch `main`, is now an **WIP** to incorporate [libuv](http://docs.libuv.org)with [c-raii](https://github.com/zelang-dev/c-raii). See `branches` for previous setup.
16
+
This library provides **ease of use***convenience* wrappers for **[libuv](http://docs.libuv.org)** combined with the power of **[c-raii](https://zelang-dev.github.io/c-raii)**, a **high level memory management** library similar to other languages, among other features. Like **[coroutine](https://github.com/zelang-dev/c-raii/blob/main/include/coro.h)** support, the otherwise **callback** needed, is now automatically back to the caller with *results*.
17
17
18
-
There seems a similar approach has been made for ***C++20***, an implementation in [uvco](https://github.com/dermesser/uvco).
19
-
The *[tests](https://github.com/dermesser/uvco/tree/master/test)* presented there currently being reimplemented for *C89* here, this project will be considered stable when *completed*.
18
+
* All functions requiring *allocation* and *passing***pointers**, now returns them instead, if needed.
19
+
* The general naming convention is to drop **~~uv_~~** prefix and require only *necessary* arguments/options.
20
+
* This integration also requires the use of **`uv_main(int argc, char **argv)`** as the *startup* entry routine:
21
+
22
+
**libuv** example from <https://github.com/libuv/libuv/tree/master/docs/code/>
23
+
24
+
<table>
25
+
<tr>
26
+
<th>helloworld.c</th>
27
+
<th>helloworld/main.c</th>
28
+
</tr>
29
+
<tr>
30
+
<td>
31
+
32
+
```c
33
+
#include"uv_coro.h"
34
+
35
+
intuv_main(int argc, char **argv) {
36
+
printf("Now quitting.\n");
37
+
yielding();
38
+
39
+
return coro_err_code();
40
+
}
41
+
```
42
+
43
+
</td>
44
+
<td>
45
+
46
+
```c
47
+
#include <stdio.h>
48
+
#include <stdlib.h>
49
+
#include <uv.h>
50
+
51
+
int main() {
52
+
uv_loop_t *loop = malloc(sizeof(uv_loop_t));
53
+
uv_loop_init(loop);
54
+
55
+
printf("Now quitting.\n");
56
+
uv_run(loop, UV_RUN_DEFAULT);
57
+
58
+
uv_loop_close(loop);
59
+
free(loop);
60
+
return 0;
61
+
}
62
+
```
63
+
64
+
</td>
65
+
</tr>
66
+
</table>
67
+
68
+
**This general means there will be a dramatic reduction of lines of code repeated, repeatedly.**
69
+
70
+
*Libuv guides/examples:*
71
+
72
+
*[Reading/Writing files](https://docs.libuv.org/en/v1.x/guide/filesystem.html#reading-writing-files) as in [uvcat/main.c](https://github.com/libuv/libuv/blob/master/docs/code/uvcat/main.c) - 62 line *script*.
73
+
*[Buffers and Streams](https://docs.libuv.org/en/v1.x/guide/filesystem.html#buffers-and-streams) as in [uvtee/main.c](https://github.com/libuv/libuv/blob/master/docs/code/uvtee/main.c) - 79 line *script*.
74
+
*[Networking/TCP](https://docs.libuv.org/en/v1.x/guide/networking.html#tcp) as in [tcp-echo-server/main.c](https://github.com/libuv/libuv/blob/master/docs/code/tcp-echo-server/main.c) - 87 line *script*.
See `branches` for previous setup, `main` is an complete makeover of previous implementation approaches.
174
+
175
+
Similar approach has been made for ***C++20***, an implementation in [uvco](https://github.com/dermesser/uvco).
176
+
The *[tests](https://github.com/dermesser/uvco/tree/master/test)* presented there currently being reimplemented for *C89* here, this project will be considered stable when *completed*. And another approach in [libasync](https://github.com/btrask/libasync) mixing [libco](https://github.com/higan-emu/libco) with **libuv**. Both approaches are **Linux** only.
20
177
21
178
## Synopsis
22
179
@@ -26,18 +183,18 @@ The *[tests](https://github.com/dermesser/uvco/tree/master/test)* presented ther
26
183
27
184
## Usage
28
185
29
-
### See [examples](https://github.com/zelang-dev/c-coroutine/tree/main/examples) folder
186
+
### See [examples](https://github.com/zelang-dev/c-coroutine/tree/main/examples)and [tests](https://github.com/zelang-dev/c-coroutine/tree/main/tests)folder
30
187
31
188
## Installation
32
189
33
-
The build system uses **cmake**, that produces _single_**static**library stored under `built`, and the complete `include` folder is needed.
190
+
The build system uses **cmake**, that produces **static**libraries by default.
34
191
35
192
**Linux**
36
193
37
194
```shell
38
195
mkdir build
39
196
cd build
40
-
cmake .. -DCMAKE_BUILD_TYPE=Debug/Release -DBUILD_EXAMPLES=ON # use to build files in examples folder
197
+
cmake .. -D CMAKE_BUILD_TYPE=Debug/Release -D BUILD_EXAMPLES=ON -D BUILD_TESTS=ON # use to build files in tests/examples folder
41
198
cmake --build .
42
199
```
43
200
@@ -46,7 +203,7 @@ cmake --build .
46
203
```shell
47
204
mkdir build
48
205
cd build
49
-
cmake .. -D BUILD_EXAMPLES=ON # use to build files in examples folder
206
+
cmake .. -D BUILD_EXAMPLES=ON -D BUILD_TESTS=ON # use to build files in tests/examples folder
0 commit comments