Skip to content

djherbis/nio

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

nio

GoDoc Release Software License go test Coverage Status Go Report Card

Usage

The Buffer interface:

type Buffer interface {
	Len() int64
	Cap() int64
	io.ReadWriter
}

nio's Copy method concurrently copies from an io.Reader to a supplied nio.Buffer, then from the nio.Buffer to an io.Writer. This way, blocking writes don't slow the io.Reader.

import (
  "github.com/djherbis/buffer"
  "github.com/djherbis/nio/v3"
)

buf := buffer.New(32*1024) // 32KB In memory Buffer
nio.Copy(w, r, buf) // Reads and Writes concurrently, buffering using buf.

nio's Pipe method is a buffered version of io.Pipe The writer return once its data has been written to the Buffer. The reader returns with data off the Buffer.

import (
  "github.com/djherbis/buffer"
  "github.com/djherbis/nio/v3"
)

buf := buffer.New(32*1024) // 32KB In memory Buffer
r, w := nio.Pipe(buf)

Installation

go get github.com/djherbis/nio/v3

For some pre-built buffers grab:

go get github.com/djherbis/buffer

Mentions

GopherCon 2017: Peter Bourgon - Evolutionary Optimization with Go

About

Concurrent Buffered IO in Go #golang

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages