libuv, C++, gRPC

61 views
Skip to first unread message

andrew.e....@gmail.com

unread,
Dec 6, 2017, 4:52:29 PM12/6/17
to grpc.io
I have a libuv-based C++14 application and am contemplating using gRPC... however I would very much like it to use the libuv networking and thread pool services.  I see that gRPC supports a C++ implementation, and I see it supports a node.js implementation... is the intersection of the two possible?  Searching doesn't give me a quick answer.

Michael Lumish

unread,
Dec 6, 2017, 6:18:44 PM12/6/17
to andrew.e....@gmail.com, grpc.io
In principle, I think this should work, but it will probably be a little awkward because the libuv code was written to work with Node, and specifically with our own Node extension. So, there are a few caveats:

  1. The Makefile isn't set up to build the libuv code, so you'll have to set "EXTRA_CPPFLAGS" and "EXTRA_LDFLAGS" with the relevant build flags. There's an example of how we do it for our test runner here: https://github.com/grpc/grpc/blob/master/tools/run_tests/run_tests.py#L264
  2. You will have to set the variable grpc_pollset_work_run_loop to 0 after initializing the grpc library but before calling other grpc functions. That's not declared in any public headers, but I think you can just declare it as an extern int. If not, you'll have to import the header src/core/lib/iomgr/pollset_uv.h from the gRPC codebase.
  3. The code assumes that you're using the default UV loop, and doesn't provide a way to change that.
  4. It doesn't seem to work right if you run it on multiple threads, but that could be an artifact of how we test the code.

On Wed, Dec 6, 2017 at 1:52 PM <andrew.e....@gmail.com> wrote:
I have a libuv-based C++14 application and am contemplating using gRPC... however I would very much like it to use the libuv networking and thread pool services.  I see that gRPC supports a C++ implementation, and I see it supports a node.js implementation... is the intersection of the two possible?  Searching doesn't give me a quick answer.

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/c1998ba3-6eac-4b6c-8acc-99dae78a9a73%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages