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 <[email protected]> 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 [email protected]. > To post to this group, send email to [email protected]. > 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 > <https://groups.google.com/d/msgid/grpc-io/ad2ee22e-9b55-42f5-905c-1928ea274468%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. To post to this group, send email to [email protected]. 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/CALUXJ7iWGNk8ev3h2Hq7haiGGVU-8rxs%3DSvwj-tvaWwdCmc7Xw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
