netpoll

package
v1.3.78 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// InitEvents represents the initial length of poller event-list.
	InitEvents = 128
	// ErrEvents represents exceptional events that are not read/write, like socket being closed,
	// reading/writing from/to a closed socket, etc.
	ErrEvents = unix.EPOLLERR | unix.EPOLLHUP | unix.EPOLLRDHUP
	// OutEvents combines EPOLLOUT event and some exceptional events.
	OutEvents = ErrEvents | unix.EPOLLOUT
	// InEvents combines EPOLLIN/EPOLLPRI events and some exceptional events.
	InEvents = ErrEvents | unix.EPOLLIN | unix.EPOLLPRI
)

Variables

This section is empty.

Functions

func Dup

func Dup(fd int) (int, string, error)

Dup is the wrapper for dupCloseOnExec.

func SetKeepAlive

func SetKeepAlive(fd, secs int) error

SetKeepAlive sets the keepalive for the connection.

func SockaddrToTCPOrUnixAddr

func SockaddrToTCPOrUnixAddr(sa unix.Sockaddr) net.Addr

SockaddrToTCPOrUnixAddr converts a Sockaddr to a net.TCPAddr or net.UnixAddr. Returns nil if conversion fails.

func SockaddrToUDPAddr

func SockaddrToUDPAddr(sa unix.Sockaddr) net.Addr

SockaddrToUDPAddr converts a Sockaddr to a net.UDPAddr Returns nil if conversion fails.

Types

type Poller

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

Poller represents a poller which is in charge of monitoring file-descriptors.

func OpenPoller

func OpenPoller() (poller *Poller, err error)

OpenPoller instantiates a poller.

func (*Poller) AddRead

func (p *Poller) AddRead(fd int) error

AddRead registers the given file-descriptor with readable event to the poller.

func (*Poller) AddReadWrite

func (p *Poller) AddReadWrite(fd int) error

AddReadWrite registers the given file-descriptor with readable and writable events to the poller.

func (*Poller) AddWrite

func (p *Poller) AddWrite(fd int) error

AddWrite registers the given file-descriptor with writable event to the poller.

func (*Poller) Close

func (p *Poller) Close() error

Close closes the poller.

func (*Poller) Delete

func (p *Poller) Delete(fd int) error

Delete removes the given file-descriptor from the poller.

func (*Poller) ModRead

func (p *Poller) ModRead(fd int) error

ModRead renews the given file-descriptor with readable event in the poller.

func (*Poller) ModReadWrite

func (p *Poller) ModReadWrite(fd int) error

ModReadWrite renews the given file-descriptor with readable and writable events in the poller.

func (*Poller) Polling

func (p *Poller) Polling(callback func(fd int, ev uint32) error) error

Polling blocks the current goroutine, waiting for network-events.

func (*Poller) Trigger

func (p *Poller) Trigger(job internal.Job) (err error)

Trigger wakes up the poller blocked in waiting for network-events and runs jobs in asyncJobQueue.

Jump to

Keyboard shortcuts

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