poller

package
v0.0.0-...-14c233f Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrClosed = errors.New("poller instance is not running")

ErrClosed 错误: 重复 close poller 错误

Functions

This section is empty.

Types

type Event

type Event uint32

Event:poller 返回事件

const (
	EventRead  Event = 0x1
	EventWrite Event = 0x2
	EventErr   Event = 0x80
	EventNone  Event = 0
)

Event poller 返回事件值

type Poller

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

Poller:结构体封装

func Create

func Create() (*Poller, error)

Create:创建一个 Poller

func (*Poller) AddRead

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

AddRead:注册需要关注的 fd 到 epoll,并注册为可读事件

func (*Poller) AddWrite

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

AddWrite:注册 fd 到 epoll,并注册可写事件

func (*Poller) Close

func (ep *Poller) Close() (err error)

Close:关闭

func (*Poller) Del

func (ep *Poller) Del(fd int) error

Del:从 epoll 中删除对应的 fd 事件

func (*Poller) EnableRead

func (ep *Poller) EnableRead(fd int) error

EnableRead:修改 fd 注册事件为可读事件

func (*Poller) EnableReadWrite

func (ep *Poller) EnableReadWrite(fd int) error

EnableReadWrite:修改 fd 注册事件为可读可写事件

func (*Poller) EnableWrite

func (ep *Poller) EnableWrite(fd int) error

EnableWrite:修改 fd 注册事件为可写事件

func (*Poller) Poll

func (ep *Poller) Poll(handler func(fd int, event Event))

Poll:启动 epoll 进行事件读写等待循环

func (*Poller) Wake

func (ep *Poller) Wake() error

Wake:唤醒调用

Jump to

Keyboard shortcuts

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