From 76f4548b85de6e2c36d295223f3a4fd3fbca6314 Mon Sep 17 00:00:00 2001 From: Sebastian Zagrodzki Date: Wed, 26 Apr 2017 22:49:37 +0200 Subject: [PATCH] Add info about concurrency safety for stream. --- usb/transfer_stream.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/usb/transfer_stream.go b/usb/transfer_stream.go index c782474..a1a9163 100644 --- a/usb/transfer_stream.go +++ b/usb/transfer_stream.go @@ -59,6 +59,7 @@ type ReadStream struct { // might be smaller than the length of p. // After a non-nil error is returned, all subsequent attempts to read will // return io.ErrClosedPipe. +// Read cannot be called concurrently with other Read or Close. func (r ReadStream) Read(p []byte) (int, error) { s := r.s if s.transfers == nil { @@ -117,6 +118,7 @@ func (r ReadStream) Read(p []byte) (int, error) { // subsequent Read()s will return data from all transfers that were already // in progress before returning an io.EOF error, unless another error // was encountered earlier. +// Close cannot be called concurrently with Read. func (r ReadStream) Close() { r.s.setDelayedErr(io.EOF) }