UniversityRadioYork/playslave-plusplus — pull request #12 by CaptainHayashi (2014-08-18 21:32:55+00:00)
Title: Libuv

# libuv

This branch aims to replace [boost::asio][] with [libuv][], and [boost::tokenizer][] with our own tokeniser implementing [shell syntax][]. More generally, it's an attempt to remove Boost as a dependency (it'd have been called the _deboost_ branch, if I'd thought more about the nomenclature).

libuv is a C asynchronous I/O library. It's basically very much like asio, but seems to be a bit more lightweight and easy to work with. The main reason I've been trying out libuv is to see if it behaves better with regards to CPU hogging, but really that was mostly an excuse to give it a whirl :grin:

A major disadvantage is that, because it's a C library with callbacks, there is a __lot__ of `void*` juggling and (probably) some memory leaking, but thankfully this is all contained within the `io_reactor.cpp` file.

Since, to use libuv, we can't easily send lines from clients to the `CommandHandler`, I decided to rewrite the tokeniser. The new `Tokeniser` object implements a subset of [shell syntax][], and can deal with being sent strings of less or more than one line in length.

## Todo

* [ ] Try on Linux, check CPU usage (it seems to behave quite well on Windows)
* [ ] See if we can do connection management better than the somewhat hodgepodge `shared_ptr` `set`
* [ ] Remove remaining traces of Boost
* [ ] Fix Makefile
* [ ] Update compilation instructions
* [ ] Check (eyeballs and Valgrind) for memory leaks and incorrect usage of libuv
* [ ] Doxygen
* [ ] Clang-format
* [ ] Clean-up and test tokeniser
* [ ] Tokeniser error handling

[shell syntax]: http://pubs.opengroup.org/onlinepubs/009604599/utilities/xcu_chap02.html
[boost::asio]: http://www.boost.org/doc/libs/1_56_0/doc/html/boost_asio.html
[boost::tokenizer]: http://www.boost.org/doc/libs/1_56_0/libs/tokenizer/
[libuv]: https://github.com/joyent/libuv