c++ Callback API

407 views
Skip to first unread message

Viktor Khristenko

unread,
Jan 8, 2022, 2:16:44 PM1/8/22
to grpc.io
Hello,

I'm using c++ callback api, specified here: https://github.com/grpc/proposal/pull/180/files

i have 1 question about client (in particular, but i would guess this is more general) side, streaming write reactor.

client streaming write reactor has these (among others) methods:
- StartCall
- OnDone

Spec says that "No further RPC operations are permitted to be issued after `OnDone` is invoked". question: What happens when you have
- 1 thread doing StartCall on a reactor, with subsequent StartWrite
- OnDone was called on the same reactor but from a different thread.

Thanks a lot for any insight!

VK

Viktor Khristenko

unread,
Jan 9, 2022, 6:50:31 AM1/9/22
to grpc.io
I think, i've misunderstood the spec slightly and also checked examples (e.g. route_guide callback client/server). noting here for reference

to answer my question (rephrased slightly):
if one has no holds and one calls StartWrite (outside of a reactor) in an app thread and OnDone() is called by grpc library thread - this is possible... and 
from what i understand the spec __does not__ say anything about this situation - I mean to me not clear what happens...! 
The suggested way to avoid it in here is to add a hold before StartCall and remove it when onWriteDone returns not ok.  

1 thing, for me was not clear, given the spec says "the above calls may take place concurrently, except that `OnDone` will always take place after all other reactions"
what this really means is that if u are __directly reading/writing__ from within a reactor, u do not need holds, u need them only if you are reading/writing from outside of the reactor... the client_callback.h even states that this is __not__ an common use of streaming api...  which is a bit strange to me, may be i'm biased... 

thanks!

VK

Reply all
Reply to author
Forward
0 new messages