netpoll

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 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 = 64
	// MaxPollEventsCap is the maximum limitation of events that the poller can process.
	MaxPollEventsCap = 512
	// MinPollEventsCap is the minimum limitation of events that the poller can process.
	MinPollEventsCap = 16
	// MaxAsyncTasksAtOneTime is the maximum amount of asynchronous tasks that the event-loop will process at one time.
	MaxAsyncTasksAtOneTime = 128
)

Variables

This section is empty.

Functions

This section is empty.

Types

type IOEvent

type IOEvent = int16

IOEvent is the integer type of I/O events on BSD's.

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

NewPoller 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) AddWrite

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

func (*Poller) Close

func (p *Poller) Close() error

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