diff --git a/lib.go b/lib.go index 0c6468a..dadcd41 100644 --- a/lib.go +++ b/lib.go @@ -52,7 +52,7 @@ var ( ErrZeroAllocation = errors.New("zero allocation") // ErrAbort is returned to the writer process in case of buffered content, when the reader - // experienced an error. ErrAbort is returned to the reader process, if Abort() was called and no read + // experienced an error. ErrAbort is returned to the reader process, if Close() was called and no read // error was received before it. ErrAbort = errors.New("read aborted") ) @@ -211,9 +211,9 @@ func (r Reader) WriteTo(w io.Writer) (int64, error) { return r.reader.writeTo(w) } -// Abort releases the resource held by the Reader, and puts back the underlying byte buffers into the used pool. -// The reader cannot be used for read operations after Abort() was called. -func (r Reader) Abort() { +// Close releases the resource held by the Reader, and puts back the underlying byte buffers into the used pool. +// The reader cannot be used for read operations after Close() was called. +func (r Reader) Close() { if r.reader == nil { return } diff --git a/lib_test.go b/lib_test.go index bfd122b..3168ec7 100644 --- a/lib_test.go +++ b/lib_test.go @@ -155,7 +155,7 @@ func TestLib(t *testing.T) { t.Run("from blank state", func(t *testing.T) { p := &fakePool{allocSize: 1 << 6} r := buffer.BufferedReader(&gen{max: 1 << 12}, buffer.Options{Pool: p}) - r.Abort() + r.Close() b := make([]byte, 1<<9) n, err := r.Read(b) if n != 0 || !errors.Is(err, buffer.ErrAbort) { @@ -175,7 +175,7 @@ func TestLib(t *testing.T) { t.Fatal(len(b), ok, err, p.alloc) } - r.Abort() + r.Close() b = make([]byte, 1<<9) n, err := r.Read(b) if n != 0 || !errors.Is(err, buffer.ErrAbort) { @@ -206,7 +206,7 @@ func TestLib(t *testing.T) { t.Fatal(n, err) } - r.Abort() + r.Close() b = make([]byte, 1<<9) n, err = r.Read(b) if n != 0 || !errors.Is(err, errTest) { @@ -247,7 +247,7 @@ func TestLib(t *testing.T) { } } - r.Abort() + r.Close() n, err := r.Read(b) if n != 0 || !errors.Is(err, buffer.ErrAbort) { t.Fatal(n, err) @@ -292,7 +292,7 @@ func TestLib(t *testing.T) { t.Fatal(n, err) } - r.Abort() + r.Close() n, err = r.Read(b) if n != 0 || !errors.Is(err, errTest) { t.Fatal(n, err)