For ClientAsyncStreamingInterface::Finish and for ServerAsyncReaderWriterInterface::Finish the documentation says:
"Should not be used concurrently with other operations"
Does that mean there shouldn't be any outstanding Writes / Reads when this function is called? Or just that there shouldn't be a call to "Finish" when a call to "Read" or "Write" is in progress (as in multiple threads competing with each other)? I didn't see a problem with an outstanding read when I tested (by issuing a read, closing server side, closing client side in parallel) this, but just wanna confirm what’s ideal.
For ClientAsyncStreamingInterface::Finish the doc says:
"
/// It is appropriate to call this method exactly once when both:
/// * the client side has no more message to send
/// (this can be declared implicitly by calling this method, or
/// explicitly through an earlier call to the <i>WritesDone</i> method
/// of the class in use, e.g. \a ClientAsyncWriterInterface::WritesDone or
/// \a ClientAsyncReaderWriterInterface::WritesDone).
"
Does this mean that a call to "WritesDone" before calling "Finish" is optional and I can just directly call "Finish" instead? If yes, in what circumstances would one find calling "WritesDone" before "Finish" useful?
The documentation for CompletionQueue::Next says that for a client-side Read, a call to Next returns not-ok only when the "call is dead". What all does that exactly mean? What constitutes a "call"? I thought it could be not-ok if the server-side or client-side is already "Finish"-ed or if the underlying network was compromised.
Also, is it ok to invoke ClientAsyncStreamingInterface::Finish before the server has sent all its messages and before a AsyncReaderInterface::Read yields a not-ok tag? I see that the second point in documentation for this "Finish" instructs exactly against such a usage, but I just wanted to confirm if it's an illegal usage and could result in run time errors (assert fails) from grpc code?
Test: for not_ok_grpc_status “Finish” completes, but as even the doc states the “Finish” tag never comes out (as all the incoming messages have not been read by the client) when server responds with grpc_ok which may lead to minor resource_leaks? Can such usage lead to crashes?
Also, what's the accepted way to close the streams when it's not implicitly known that no more messages are to be received from the server? Would it be:
1. Invoke 'WritesDone'.
2. Wait for AsyncReaderInterface::Read to yield a not-ok tag.
3. Finish the stream.