netpoll

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// InitPollEventsCap represents the initial capacity of poller event-list.
	InitPollEventsCap = 128
	// MaxPollEventsCap is the maximum limitation of events that the poller can process.
	MaxPollEventsCap = 1024
	// MinPollEventsCap is the minimum limitation of events that the poller can process.
	MinPollEventsCap = 32
	// MaxAsyncTasksAtOneTime is the maximum amount of asynchronous tasks that the event-loop will process at one time.
	MaxAsyncTasksAtOneTime = 256
	// 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
)
View Source
const EPOLLET = -syscall.EPOLLET

Variables

This section is empty.

Functions

func EpollCreate

func EpollCreate(flag int) (fd int, err error)

EpollCreate implements epoll_create1.

func EpollCtl

func EpollCtl(epfd int, op int, fd int, event *epollevent) (err error)

EpollCtl implements epoll_ctl.

func EpollWait

func EpollWait(epfd int, events []epollevent, msec int) (n int, err error)

EpollWait implements epoll_wait.

Types

type IOEvent

type IOEvent = uint32

IOEvent is the integer type of I/O events on Linux.

type PollEvent

type PollEvent int
const (
	PollEventUnknown PollEvent = 1 << iota // 未知事件
	PollEventRead                          // 读事件
	PollEventWrite                         // 写事件
	PollEventClose                         // 错误事件
)

type Poller

type Poller struct {
	wklog.Log
	// contains filtered or unexported fields
}

func NewPoller

func NewPoller(name string) *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) AddWrite

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

func (*Poller) Close

func (p *Poller) Close() error

Close closes the poller.

func (*Poller) Delete

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

func (*Poller) DeleteRead

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

DeleteRead deletes the given file-descriptor from the poller.

func (*Poller) DeleteReadAndWrite

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

func (*Poller) DeleteWrite

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

DeleteWrite deletes the given file-descriptor from the poller.

func (*Poller) Polling

func (p *Poller) Polling(callback func(fd int, event PollEvent) error) error

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

Jump to

Keyboard shortcuts

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