From c6b96641801f2f7fd8085f01bff103564d84bb57 Mon Sep 17 00:00:00 2001 From: Menghan Li Date: Thu, 15 Jun 2017 15:24:17 -0700 Subject: [PATCH] Add goroutine safety doc on stream (#1313) --- stream.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/stream.go b/stream.go index cac07f5e..3c787844 100644 --- a/stream.go +++ b/stream.go @@ -58,11 +58,17 @@ type Stream interface { // side. On server side, it simply returns the error to the caller. // SendMsg is called by generated code. Also Users can call SendMsg // directly when it is really needed in their use cases. + // It's safe to have a goroutine calling SendMsg and another goroutine calling + // recvMsg on the same stream at the same time. + // But it is not safe to call SendMsg on the same stream in different goroutines. SendMsg(m interface{}) error // RecvMsg blocks until it receives a message or the stream is // done. On client side, it returns io.EOF when the stream is done. On // any other error, it aborts the stream and returns an RPC status. On // server side, it simply returns the error to the caller. + // It's safe to have a goroutine calling SendMsg and another goroutine calling + // recvMsg on the same stream at the same time. + // But it is not safe to call RecvMsg on the same stream in different goroutines. RecvMsg(m interface{}) error }