Package-Level Type Names (total 6, in which 1 is exported)
/* sort exporteds by: | */
Reader is an optional interface that can be implemented by [net.Conn]
implementations to enable gRPC to perform non-memory-pinning reads. ReadOnReady waits for data to arrive, fetches a buffer, and performs a
read. When the underlying IO is readable, it allocates a buffer of size
bufSize from the pool and reads up to bufSize bytes into the buffer.
It returns a pointer to the buffer so it can be returned to the pool
later, the number of bytes read, and an error.
Callers should always process the n > 0 bytes returned before considering
the error. Doing so correctly handles I/O errors that happen after
reading some bytes, as well as both of the allowed EOF behaviors.
*blockingReader
*nonBlockingReader
func New(r io.Reader) Reader
func NewNonBlocking(r io.Reader) Reader
func NewBuffered(rd Reader, size int, pool mem.BufferPool) io.Reader
bufReadyReader implements buffering for a ReadyReader object.
A new bufReadyReader is created by calling [NewBuffered].buf*[]bytebufSizeint // stored as a field to avoid heap allocations.errerrorpoolmem.BufferPool // buf read and write positions // reader provided by the caller // buf read and write positions Read reads data into p. It returns the number of bytes read into p. The
bytes are taken from at most one Read on the underlying [ReadyReader],
hence n may be less than len(p). If the underlying [ReadyReader] can return
a non-zero count with io.EOF, then this Read method can do so as well; see
the [io.Reader] docs.(*bufReadyReader) buffered() int(*bufReadyReader) readErr() error
*bufReadyReader : io.Reader
nonBlockingReader is optimized for non-memory-pinning reads using the RawConn
interface.doReadfunc(fd uintptr) boolrawsyscall.RawConn The following fields are stored as field to avoid heap allocations.(*nonBlockingReader) ReadOnReady(bufSize int, pool mem.BufferPool) (*[]byte, int, error)
*nonBlockingReader : Reader
Package-Level Functions (total 6, in which 3 are exported)
New detects if [syscall.RawConn] is available for non-memory-pinning reads.
If [syscall.RawConn] is unavailable, it falls back to using the simpler
[io.Reader] interface for reads.
NewBuffered returns a new [io.Reader] with a buffer of the specified size
which is allocated from the provided pool.
NewNonBlocking returns a ReadyReader if the passed reader supports
non-memory-pinning reads, else nil.
sysRead uses the standard syscall package rather than the modern unix package
to avoid triggering the race detector. Because both packages perform sync
operations on a local variable to satisfy the race detector, mixing them
for read and write syscalls causes data races. We use syscall here to remain
consistent with net.Conn implementations in standard library.
wouldBlock checks standard Unix non-blocking errors.
The pages are generated with Goldsv0.8.4. (GOOS=linux GOARCH=amd64)