Add goroutine safety doc on stream (#1313)

This commit is contained in:
Menghan Li 2017-06-15 15:24:17 -07:00 коммит произвёл GitHub
Родитель 834dbd54e0
Коммит c6b9664180
1 изменённых файлов: 6 добавлений и 0 удалений

Просмотреть файл

@ -58,11 +58,17 @@ type Stream interface {
// side. On server side, it simply returns the error to the caller. // side. On server side, it simply returns the error to the caller.
// SendMsg is called by generated code. Also Users can call SendMsg // SendMsg is called by generated code. Also Users can call SendMsg
// directly when it is really needed in their use cases. // 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 SendMsg(m interface{}) error
// RecvMsg blocks until it receives a message or the stream is // 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 // 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 // any other error, it aborts the stream and returns an RPC status. On
// server side, it simply returns the error to the caller. // 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 RecvMsg(m interface{}) error
} }