Documentation
¶
Index ¶
- Constants
- func Dup(fd int) (int, string, error)
- func PutPollAttachment(pa *PollAttachment)
- type PollAttachment
- type PollEventHandler
- type Poller
- func (p *Poller) AddRead(pa *PollAttachment) error
- func (p *Poller) AddReadWrite(pa *PollAttachment) error
- func (p *Poller) AddWrite(pa *PollAttachment) error
- func (p *Poller) Close() error
- func (p *Poller) Delete(_ int) error
- func (p *Poller) ModRead(pa *PollAttachment) error
- func (p *Poller) ModReadWrite(pa *PollAttachment) error
- func (p *Poller) Polling(callback func(fd int, filter int16) error) error
- func (p *Poller) Trigger(fn queue.TaskFunc, arg interface{}) (err error)
- func (p *Poller) UrgentTrigger(fn queue.TaskFunc, arg interface{}) (err error)
Constants ¶
const ( // InitPollEventsCap represents the initial capacity of poller event-list. InitPollEventsCap = 64 // MaxAsyncTasksAtOneTime is the maximum amount of asynchronous tasks that the event-loop will process at one time. MaxAsyncTasksAtOneTime = 128 // EVFilterWrite represents writeable events from sockets. EVFilterWrite = unix.EVFILT_WRITE // EVFilterRead represents readable events from sockets. EVFilterRead = unix.EVFILT_READ // EVFilterSock represents exceptional events that are not read/write, like socket being closed, // reading/writing from/to a closed socket, etc. EVFilterSock = -0xd )
Variables ¶
This section is empty.
Functions ¶
func PutPollAttachment ¶ added in v1.5.2
func PutPollAttachment(pa *PollAttachment)
PutPollAttachment put a unused PollAttachment back to pool.
Types ¶
type PollAttachment ¶ added in v1.5.2
type PollAttachment struct { FD int Callback PollEventHandler }
PollAttachment is the user data which is about to be stored in "void *ptr" of epoll_data or "void *udata" of kevent.
func GetPollAttachment ¶ added in v1.5.2
func GetPollAttachment() *PollAttachment
GetPollAttachment attempts to get a cached PollAttachment from pool.
type PollEventHandler ¶ added in v1.5.2
PollEventHandler is the callback for I/O events notified by the poller.
type Poller ¶
type Poller struct {
// contains filtered or unexported fields
}
Poller represents a poller which is in charge of monitoring file-descriptors.
func (*Poller) AddRead ¶
func (p *Poller) AddRead(pa *PollAttachment) error
AddRead registers the given file-descriptor with readable event to the poller.
func (*Poller) AddReadWrite ¶
func (p *Poller) AddReadWrite(pa *PollAttachment) error
AddReadWrite registers the given file-descriptor with readable and writable events to the poller.
func (*Poller) AddWrite ¶
func (p *Poller) AddWrite(pa *PollAttachment) error
AddWrite registers the given file-descriptor with writable event to the poller.
func (*Poller) ModRead ¶
func (p *Poller) ModRead(pa *PollAttachment) error
ModRead renews the given file-descriptor with readable event in the poller.
func (*Poller) ModReadWrite ¶
func (p *Poller) ModReadWrite(pa *PollAttachment) error
ModReadWrite renews the given file-descriptor with readable and writable events in the poller.
func (*Poller) Trigger ¶
Trigger is like UrgentTrigger but it puts task into asyncTaskQueue, call this method when the task is not so urgent, for instance writing data back to client.
Note that asyncTaskQueue is a queue with low-priority whose size may grow large and tasks in it may backlog.
func (*Poller) UrgentTrigger ¶ added in v1.5.0
UrgentTrigger puts task into priorAsyncTaskQueue and wakes up the poller which is waiting for network-events, then the poller will get tasks from priorAsyncTaskQueue and run them.
Note that priorAsyncTaskQueue is a queue with high-priority and its size is expected to be small, so only those urgent tasks should be put into this queue.