--
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+unsubscribe@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/ad2ee22e-9b55-42f5-905c-1928ea274468%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
If you're just wanting the client to send one request every time it receives a response, you can typically ignore #isReady() and let the automatic flow-control handle things. If you need to do something more complicated, like manually handling flow control, CallStreamObserver#setOnReadyHandler will let you register a callback when the #isReady() state changes from false to true. You can see an example using this in the manual flow control client example code, https://github.com/grpc/grpc-java/blob/c9b02db276403db4794c6e5ffc78b46889cd4ce8/examples/src/main/java/io/grpc/examples/manualflowcontrol/ManualFlowControlClient.java#L70.
On Sun, Dec 31, 2017 at 7:07 PM, Matt Mitchell <good...@gmail.com> wrote:
Hi,I'm using onReady() to initialize my client connection (a long lived bidi connection) and then using isReady() like:public void onNext(MyMessage msg) {while( ! requestStream.isReady() ){ sleep-for-som-short-time }requestStream.request(1);requestStream.onNext(msg);}Which seems to work fine, but it also causes high CPU usage. Is there a better way to handle sending messages from the client to server without looping + sleeping like this?Thanks,- Matt
--
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.
The way my service works is the client will establish a bidi stream. The server then sends a message, from which the client will send n-messages back.
Since my client sends back a stream of results for each server request message, and the setOnReadyHandler call and onNext are on the same thread