Skip to content
This repository has been archived by the owner on Jan 15, 2020. It is now read-only.

Latest commit

 

History

History
129 lines (69 loc) · 2.09 KB

README.md

File metadata and controls

129 lines (69 loc) · 2.09 KB

poller

import "github.com/pkg/poller"

Package poller provides level triggered readiness notification and reliable closing of file descriptors.

type Pollable

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

Pollable represents a file descriptor that can be read/written and polled/waited for readiness notification.

func (*Pollable) Close

func (p *Pollable) Close() error

Close deregisters the Pollable and closes the underlying file descriptor.

func (*Pollable) Read

func (p *Pollable) Read(b []byte) (int, error)

Read reads up to len(b) bytes from the underlying fd. It returns the number of bytes read and an error, if any. EOF is signaled by a zero count with err set to io.EOF.

Callers to Read will block if there is no data available to read.

func (*Pollable) WaitRead

func (p *Pollable) WaitRead() error

WaitRead waits for the Pollable to become ready for reading.

func (*Pollable) WaitWrite

func (p *Pollable) WaitWrite() error

WaitWrite waits for the Pollable to become ready for writing.

func (*Pollable) Write

func (p *Pollable) Write(b []byte) (int, error)

Write writes len(b) bytes to the fd. It returns the number of bytes written and an error, if any. Write returns a non-nil error when n != len(b).

Callers to Write will block if there is no buffer capacity available.

type Poller

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

A Poller provides readiness notification and reliable closing of registered file descriptors.

func New

func New() (*Poller, error)

New creates a new Poller.

func (*Poller) Register

func (p *Poller) Register(fd uintptr) (*Pollable, error)

Register registers a file describtor with the Poller and returns a Pollable which can be used for reading/writing as well as readiness notification.

File descriptors registered with the poller will be placed into non-blocking mode.


Generated by godoc2md