use libuv thread functions to ease portability, and hopefully work around #178