eventloop

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventLoop

type EventLoop struct {
	Num int // 数量
	// contains filtered or unexported fields
}

func NewEventLoop

func NewEventLoop(num int) *EventLoop

func (*EventLoop) AddRead

func (e *EventLoop) AddRead(conn iface.IConnect) error

AddRead 添加读事件

func (*EventLoop) Init

func (e *EventLoop) Init(connectMgr iface.IConnectManager) error

Init 初始化poller

func (*EventLoop) Remove

func (e *EventLoop) Remove(conn iface.IConnect) error

Remove 删除某个连接

func (*EventLoop) Start

func (e *EventLoop) Start(emitCh chan<- iface.IRequest)

Start 执行epoll_wait

func (*EventLoop) Stop

func (e *EventLoop) Stop()

Stop 关闭epoll

type Poller

type Poller struct {
	Epfd       int                   // eventpoll fd
	Events     []unix.Kevent_t       //
	ConnectMgr iface.IConnectManager //
}

func NewPoller

func NewPoller(connectMgr iface.IConnectManager) (*Poller, error)

NewPoller 创建kqueue

func (*Poller) AddRead

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

func (*Poller) AddWrite

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

func (*Poller) Close

func (p *Poller) Close() error

func (*Poller) DoWrite added in v0.0.3

func (p *Poller) DoWrite(conn iface.IConnect) error

DoWrite 将之前未发送完毕的数据,继续发送出去

func (*Poller) GetConnectMgr added in v0.0.4

func (p *Poller) GetConnectMgr() iface.IConnectManager

GetConnectMgr .

func (*Poller) ModRead added in v0.0.3

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

ModRead 将事件修改为读

func (*Poller) ModWrite added in v0.0.3

func (p *Poller) ModWrite(fd, connID int) error

ModWrite 将事件修改为写

func (*Poller) Remove

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

func (*Poller) Wait

func (p *Poller) Wait(emitCh chan<- iface.IRequest)

Wait 这里处理的是socket的读

Jump to

Keyboard shortcuts

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