port to libuv threads and mutex