libuv integration

Sep 16, 2014 at 5:25 PM
Hi,

Is there any chance of being able to use the http_client code with the libuv event loop instead of boost asio?

For example, you can do this with lib curl: http://curl.haxx.se/libcurl/c/multi-uv.html
with the libuv event loop and a uv_poll_t structure.

I can't find yet anything in the docs or headers that indicate something similar would be possible here. I understand if there's not as libuv is strictly a c api that isn't c++-11 aware and casablanca appears targeted strictly at c++ environments.

Thanks for any tips,
Wynn
Sep 16, 2014 at 7:24 PM
Hi Wynn,

It's an interesting idea. I see two main issues though:
  • Casablanca is built with true multi-threading in mind. Libuv, since it's from the javascript world, is fundamentally (asynchronous) single-threaded. Within the core, we try very hard to avoid using this assumption (no mutexes, for example), but it's not 100%. Within user code, a single call to .get() or .wait() will result in a deadlock unless you're certain the task has already completed.
  • We make good use of several higher-level ASIO features such as OpenSSL integration. If I'm not mistaken, these aren't present in Libuv since it's more general and less specialized. Some things could be left out at the cost of features, some things might need to be patched over or re-implemented.
I doubt the C++11 vs. C issue will be a problem if these first two can be overcome. The first step would be replacing the PPLX Scheduler with hooks into libuv.

http://microsoft.github.io/cpprestsdk/pplxinterface_8h_source.html

You may also find the MSDN documentation on the PPL very useful:

http://msdn.microsoft.com/en-us/library/dd492418.aspx

After that, I'm unsure. If you're successful, please let us know! A lot of good things could come out of node.js integration :)

roschuma
Sep 16, 2014 at 11:07 PM
Thanks for the ideas - that's pretty much what I guessed the answer was.

This is a great library, coming from a linux/python/c++ world it's almost exactly what I want. But, the tight coupling to boost is too big of a hurdle for me right now, and doing the work for that is more than I want to bite off right now.

Keep up the good work,
Wynn