rclone: github.com/rclone/rclone/fs/asyncreader Index | Files

package asyncreader

import "github.com/rclone/rclone/fs/asyncreader"

Package asyncreader provides an asynchronous reader which reads independently of write

Index

Package Files

asyncreader.go

Constants

const (
    // BufferSize is the default size of the async buffer
    BufferSize = 1024 * 1024
)

type AsyncReader Uses

type AsyncReader struct {
    // contains filtered or unexported fields
}

AsyncReader will do async read-ahead from the input reader and make the data available as an io.Reader. This should be fully transparent, except that once an error has been returned from the Reader, it will not recover.

func New Uses

func New(rd io.ReadCloser, buffers int) (*AsyncReader, error)

New returns a reader that will asynchronously read from the supplied Reader into a number of buffers each of size BufferSize It will start reading from the input at once, maybe even before this function has returned. The input can be read from the returned reader. When done use Close to release the buffers and close the supplied input.

func (*AsyncReader) Abandon Uses

func (a *AsyncReader) Abandon()

Abandon will ensure that the underlying async reader is shut down. It will NOT close the input supplied on New.

func (*AsyncReader) Close Uses

func (a *AsyncReader) Close() (err error)

Close will ensure that the underlying async reader is shut down. It will also close the input supplied on New.

func (*AsyncReader) Read Uses

func (a *AsyncReader) Read(p []byte) (n int, err error)

Read will return the next available data.

func (*AsyncReader) SkipBytes Uses

func (a *AsyncReader) SkipBytes(skip int) (ok bool)

SkipBytes will try to seek 'skip' bytes relative to the current position. On success it returns true. If 'skip' is outside the current buffer data or an error occurs, Abandon is called and false is returned.

func (*AsyncReader) WriteTo Uses

func (a *AsyncReader) WriteTo(w io.Writer) (n int64, err error)

WriteTo writes data to w until there's no more data to write or when an error occurs. The return value n is the number of bytes written. Any error encountered during the write is also returned.

Package asyncreader imports 7 packages (graph) and is imported by 3 packages. Updated 2019-07-28. Refresh now. Tools for package owners.