poll.v1: maze.io/x/poll.v1 Index | Files

package poll

import "maze.io/x/poll.v1"


Package Files

descriptor.go epoll_linux.go poll.go poll_linux.go


const (
    EPOLLIN      = unix.EPOLLIN
    EPOLLOUT     = unix.EPOLLOUT
    EPOLLPRI     = unix.EPOLLPRI
    EPOLLERR     = unix.EPOLLERR
    EPOLLHUP     = unix.EPOLLHUP
    EPOLLET      = unix.EPOLLET


var (
    ErrClosed        = errors.New("poll: closed")
    ErrRegistered    = errors.New("poll: file descriptor already registered")
    ErrNotRegistered = errors.New("poll: file descriptor not registered")
    ErrNotFiler      = errors.New("poll: could not get file descriptor")

type Config Uses

type Config struct {
    OnWaitError func(error)

Config contains the base poller configuration

type Descriptor Uses

type Descriptor struct {

Descriptor is a network connection within a poll descriptor. Its methods are not concurrent safe.

func Handle Uses

func Handle(c net.Conn, events Event) (*Descriptor, error)

Handle returns Descriptor for a net.Conn. Returned Descriptor can be passed to a Poller's Start(), Resume() and Stop() methods in the same instance.

func HandleListener Uses

func HandleListener(l net.Listener, event Event) (*Descriptor, error)

HandleListener returns Descriptor for a net.Listener.

func HandleRead Uses

func HandleRead(c net.Conn) (*Descriptor, error)

func HandleReadOnce Uses

func HandleReadOnce(c net.Conn) (*Descriptor, error)

func HandleReadWrite Uses

func HandleReadWrite(c net.Conn) (*Descriptor, error)

func HandleWrite Uses

func HandleWrite(c net.Conn) (*Descriptor, error)

func HandleWriteOnce Uses

func HandleWriteOnce(c net.Conn) (*Descriptor, error)

func NewDescriptor Uses

func NewDescriptor(fd uintptr, ev Event) *Descriptor

NewDescriptor creates a Descriptor for a custom fd.

type Event Uses

type Event uint16

Event mask

const (
    EventRead Event = 1 << iota
    EventClosed Event = 0x8000

Event types

func (Event) String Uses

func (event Event) String() string

type Poller Uses

type Poller interface {
    // Start adds desc to the observation list.
    // Note that if desc was configured with OneShot event, then poller will
    // remove it from its observation list. If you will be interested in
    // receiving events after the callback, call Resume(desc).
    // Note that Resume() call directly inside desc's callback could cause
    // deadlock.
    // Note that multiple calls with same desc will produce undefined
    // behavior.
    Start(*Descriptor, func(Event)) error

    // Stop removes desc from the observation list.
    // Note that it does not call desc.Close().
    Stop(*Descriptor) error

    // Resume enables observation of desc.
    // It is useful when desc was configured with EventOneShot.
    // It should be called only after Start().
    // Note that if there no need to observe desc anymore, you should call
    // Stop() to prevent memory leaks.
    Resume(*Descriptor) error

Poller describes a poll capable interface

func New Uses

func New(c *Config) (Poller, error)

Package poll imports 8 packages (graph). Updated 2019-02-22. Refresh now. Tools for package owners.