<commit_before># uvxx
Coroutine-based C++ bindings for libuv.

```c++
#include "yieldxx/task.hpp"
#include "uvxx/tcp.hpp"
#include <uv.h>

void handle_connection(uvxx::tcp& server)
{
	xx::spawn_task([&](xx::task&& task){
		auto client = server.accept();

		for (auto res : client.read(task))
			client.write(res); // echo!
	});
}

int main()
{
	auto loop = uv_default_loop();

	auto server = uvxx::tcp{loop};
	server.bind("::", 7000);

	xx::spawn_task([&](xx::task&& task){
		for (auto client_connected : server.listen(task, 128))
			handle_connection(server);
	});

	return uv_run(loop, UV_RUN_DEFAULT);
}
```

## Usage
```sh
git submodule add https://github.com/LEW21/yieldxx.git
git submodule add https://github.com/LEW21/uvxx.git
```

* Add yieldxx/coroutine_boost.cpp (with -lboost_context) or yieldxx/coroutine_thread.cpp (with -pthread / whatever is your std::thread using) to your build system.
* Add uvxx/{handle.cpp,stream.cpp,tcp.cpp} to your build system.
* Add -luv<commit_msg>Link to the docs.<commit_after># uvxx
[![Documentation Status](https://readthedocs.org/projects/uvxx/badge/?version=latest)](http://uvxx.readthedocs.org/en/latest/?badge=latest)

uvxx is a coroutine-based multi-platform C++ networking library that uses [yieldxx](http://github.com/LEW21/yieldxx) to provide a high-level synchronous API on top of the [libuv](http://github.com/libuv/libuv) event loop.

```c++
#include "yieldxx/task.hpp"
#include "uvxx/tcp.hpp"
#include <uv.h>

void handle_connection(uvxx::tcp& server)
{
	xx::spawn_task([&](xx::task&& task){
		auto client = server.accept();

		for (auto res : client.read(task))
			client.write(res); // echo!
	});
}

int main()
{
	auto loop = uv_default_loop();

	auto server = uvxx::tcp{loop};
	server.bind("::", 7000);

	xx::spawn_task([&](xx::task&& task){
		for (auto client_connected : server.listen(task, 128))
			handle_connection(server);
	});

	return uv_run(loop, UV_RUN_DEFAULT);
}
```

[Read the docs!](http://uvxx.readthedocs.org/en/latest/)

## Usage
```sh
git submodule add https://github.com/LEW21/yieldxx.git
git submodule add https://github.com/LEW21/uvxx.git
```

* Add yieldxx/coroutine_boost.cpp (with -lboost_context) or yieldxx/coroutine_thread.cpp (with -pthread / whatever is your std::thread using) to your build system.
* Add uvxx/{handle.cpp,stream.cpp,tcp.cpp} to your build system.
* Add -luv
{'fraction_non_alphanumeric': 0.173784355179704, 'fraction_numerical': 0.01014799154334038, 'mean_word_length': 4.827586206896552, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 5, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5667920', 'n_tokens_mistral': 927, 'n_tokens_neox': 857, 'n_words': 194}