epoll

package
v0.0.0-...-263a040 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package epoll contains a thin wrapper around the epoll(7) facility.

Using epoll from Go is unusual as the language provides facilities that normally make using it directly pointless. Epoll is strictly required for unusual kernel interfaces that use event notification but don't implement file descriptors that provide usual read/write semantics.

Index

Constants

This section is empty.

Variables

View Source
var ErrEpollClosed = errors.New("the epoll instance has been closed")

Functions

This section is empty.

Types

type Epoll

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

Epoll wraps a file descriptor which can be used for I/O readiness notification.

func Open

func Open() (*Epoll, error)

Open opens an event monitoring descriptor.

func (*Epoll) Close

func (e *Epoll) Close() error

Close closes the event monitoring descriptor.

func (*Epoll) Deregister

func (e *Epoll) Deregister(fd int) error

Deregister removes the given file descriptor from the epoll instance.

Please refer to epoll_ctl(2) and EPOLL_CTL_DEL for details.

func (*Epoll) IsClosed

func (e *Epoll) IsClosed() bool

IsClosed returns whether Close has been called on the epoll instance.

func (*Epoll) Modify

func (e *Epoll) Modify(fd int, mask Readiness) error

Modify changes the set of monitored I/O readiness events of a previously registered file descriptor.

Please refer to epoll_ctl(2) and EPOLL_CTL_MOD for details.

func (*Epoll) Register

func (e *Epoll) Register(fd int, mask Readiness) error

Register registers a file descriptor and allows observing speicifc I/O readiness events.

Please refer to epoll_ctl(2) and EPOLL_CTL_ADD for details.

func (*Epoll) RegisteredFdCount

func (e *Epoll) RegisteredFdCount() int

RegisteredFdCount returns the number of file descriptors which are currently registered to the epoll instance.

func (*Epoll) Wait

func (e *Epoll) Wait() ([]Event, error)

Wait blocks and waits for arrival of events on any of the added file descriptors.

func (*Epoll) WaitTimeout

func (e *Epoll) WaitTimeout(duration time.Duration) ([]Event, error)

WaitTimeout blocks and waits with the given timeout for arrival of events on any of the added file descriptors.

A duration value of -1 milliseconds disables timeout.

Please refer to epoll_wait(2) and EPOLL_WAIT for details.

Warning, using epoll from Golang explicitly is tricky.

type Event

type Event struct {
	Fd        int
	Readiness Readiness
}

Event describes an IO readiness event on a specific file descriptor.

type Readiness

type Readiness int

Readiness is the bit mask of aspects of readiness to monitor with epoll.

const (
	// Readable indicates readiness for reading (EPOLLIN).
	Readable Readiness = unix.EPOLLIN
	// Writable indicates readiness for writing (EPOLLOUT).
	Writable Readiness = unix.EPOLLOUT
)

func (Readiness) String

func (r Readiness) String() string

String returns readable representation of the readiness flags.

Jump to

Keyboard shortcuts

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