poll

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package poll impl io multiplexing on different systems.

Index

Constants

This section is empty.

Variables

View Source
var PollerManager *pollerManager

Functions

This section is empty.

Types

type Epoll

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

Epoll poller for epoll.

func (*Epoll) Close

func (e *Epoll) Close() error

Close implements Poll.

func (*Epoll) Register

func (e *Epoll) Register(netFd *NetFileDesc, eventType EventType) error

Register implements Poll.

func (*Epoll) Wait

func (e *Epoll) Wait() error

Wait implements Poll.

type EventType

type EventType int

EventType event type for poller

const (
	Read EventType = iota + 1
	DeleteRead
	ReadToRW
	RwToRead
	OnceWrite
)

type NetFileDesc

type NetFileDesc struct {
	// FD system fd
	FD int
	// listener for poller
	NetPollListener
}

NetFileDesc file-desc for net-fd

type NetPollListener

type NetPollListener struct {
	// OnRead will run where fd is readable
	OnRead
	// OnWrite will run where fd is writeable
	OnWrite
	// OnInterrupt will run where fd is interrupted
	OnInterrupt
}

NetPollListener listener for net poller

type OnInterrupt

type OnInterrupt func() error

OnInterrupt The callback function when the net fd state is interrupt

type OnRead

type OnRead func() error

OnRead the callback function when the net fd state is readable

type OnWrite

type OnWrite func() error

OnWrite The callback function when the net fd state is writable

type Poll

type Poll interface {
	// Register netFd in the poller. events is the type of event that the poller focus on
	Register(netFd *NetFileDesc, eventType EventType) error

	// Wait
	// poller will focus on all registered netFd, wait for netFd to satisfy the condition and
	// notify the registered listener, so it is blocked
	Wait() error

	// Close the poller
	Close() error
}

Poll define net poll interface.

func NewDefaultPoller

func NewDefaultPoller() Poll

NewDefaultPoller return a kqueue poller.

Jump to

Keyboard shortcuts

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