]> Cypherpunks repositories - gostls13.git/commitdiff
io: Pipes and ReadAt are safe to use concurrently.
authorRob Pike <r@golang.org>
Thu, 1 Mar 2012 00:24:13 +0000 (11:24 +1100)
committerRob Pike <r@golang.org>
Thu, 1 Mar 2012 00:24:13 +0000 (11:24 +1100)
Updates #1599.

R=golang-dev, bradfitz, rsc, r
CC=golang-dev
https://golang.org/cl/5708056

src/pkg/io/io.go
src/pkg/io/pipe.go

index 3e2321ce713ce3adb3b587a4995f760dff7d4dfd..7074834d6137f1aad12b0fd3cd919216efe71ce9 100644 (file)
@@ -160,6 +160,9 @@ type WriterTo interface {
 // If ReadAt is reading from an input source with a seek offset,
 // ReadAt should not affect nor be affected by the underlying
 // seek offset.
+//
+// Clients of ReadAt can execute parallel ReadAt calls on the
+// same input source.
 type ReaderAt interface {
        ReadAt(p []byte, off int64) (n int, err error)
 }
index cf05e0c1ad7e3b5fb1a906942c7583a768a12bd8..69f90510f7431454d88956483babc497215a6b3e 100644 (file)
@@ -175,6 +175,10 @@ func (w *PipeWriter) CloseWithError(err error) error {
 // with code expecting an io.Writer.
 // Reads on one end are matched with writes on the other,
 // copying data directly between the two; there is no internal buffering.
+// It is safe to call Read and Write in parallel with each other or with
+// Close. Close will complete once pending I/O is done. Parallel calls to
+// Read, and parallel calls to Write, are also safe:
+// the invidual calls will be gated sequentially.
 func Pipe() (*PipeReader, *PipeWriter) {
        p := new(pipe)
        p.rwait.L = &p.l