aio

package module
v0.0.0-...-5209c1f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2016 License: MPL-2.0 Imports: 8 Imported by: 2

README

Asynchronous IO for Go

Package aio implements asynchronous IO in Go (epoll/kqueue based).

    go get github.com/rainycape/aio

GoDoc

Documentation

Overview

Package aio implements asynchronous style IO for Go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fd

func Fd(file interface{}) (int, error)

Fd returns the underlying OS file descriptor for the given file. Currently, only *os.File is supported.

func Pipe

func Pipe(flag PipeFlag) (r *os.File, w *os.File, err error)

Pipe returns a connected pair of Files; reads from r return bytes written to w. It returns the files and an error, if any. Optionally, r or w might be set to non-blocking mode using the appropriate flags. To obtain a blocking pipe just pass 0 as the flag.

Types

type Event

type Event struct {
	File  interface{}
	Flags Flags
	Data  interface{}
}

type Flags

type Flags int
const (
	In Flags = 1 << iota
	Out
	OneShot
)

type Handler

type Handler func(ev *Event)

type PipeFlag

type PipeFlag int

PipeFlag might be used to specify options when creating a pipe.

const (
	// ReadNonBlock causes the read end of the pipe to be non-blocking.
	ReadNonBlock PipeFlag = 1 << iota
	// ReadNonBlock causes the write end of the pipe to be non-blocking.
	WriteNonBlock
)

type Set

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

func New

func New() (*Set, error)

func (*Set) Add

func (s *Set) Add(file interface{}, flags Flags, data interface{}, handler Handler) error

func (*Set) Delete

func (s *Set) Delete(file interface{}) error

func (*Set) Run

func (s *Set) Run() error

func (*Set) Stop

func (s *Set) Stop() error

func (*Set) Wait

func (s *Set) Wait(duration time.Duration) ([]*Event, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL