mirror of
https://github.com/golang/go
synced 2024-11-25 11:07:59 -07:00
io: Pipes and ReadAt are safe to use concurrently.
Updates #1599. R=golang-dev, bradfitz, rsc, r CC=golang-dev https://golang.org/cl/5708056
This commit is contained in:
parent
c50074e510
commit
5a5279e128
@ -160,6 +160,9 @@ type WriterTo interface {
|
|||||||
// If ReadAt is reading from an input source with a seek offset,
|
// If ReadAt is reading from an input source with a seek offset,
|
||||||
// ReadAt should not affect nor be affected by the underlying
|
// ReadAt should not affect nor be affected by the underlying
|
||||||
// seek offset.
|
// seek offset.
|
||||||
|
//
|
||||||
|
// Clients of ReadAt can execute parallel ReadAt calls on the
|
||||||
|
// same input source.
|
||||||
type ReaderAt interface {
|
type ReaderAt interface {
|
||||||
ReadAt(p []byte, off int64) (n int, err error)
|
ReadAt(p []byte, off int64) (n int, err error)
|
||||||
}
|
}
|
||||||
|
@ -175,6 +175,10 @@ func (w *PipeWriter) CloseWithError(err error) error {
|
|||||||
// with code expecting an io.Writer.
|
// with code expecting an io.Writer.
|
||||||
// Reads on one end are matched with writes on the other,
|
// Reads on one end are matched with writes on the other,
|
||||||
// copying data directly between the two; there is no internal buffering.
|
// 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) {
|
func Pipe() (*PipeReader, *PipeWriter) {
|
||||||
p := new(pipe)
|
p := new(pipe)
|
||||||
p.rwait.L = &p.l
|
p.rwait.L = &p.l
|
||||||
|
Loading…
Reference in New Issue
Block a user