epoll

package
v0.0.0-...-522126a Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package epoll provides an implementation of Linux's IO event notification facility. See epoll(7) for more details.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEventPoll

func NewEventPoll(ctx context.Context) *fs.File

NewEventPoll allocates and initializes a new event poll object.

Types

type EntryFlags

type EntryFlags int

EntryFlags is a bitmask that holds an entry's flags.

const (
	OneShot EntryFlags = 1 << iota
	EdgeTriggered
)

Valid entry flags.

type Event

type Event struct {
	// Events is the event mask containing the set of events that have been
	// observed on an entry.
	Events uint32

	// Data is an opaque 64-bit value provided by the caller when adding the
	// entry, and returned to the caller when the entry reports an event.
	Data [2]int32
}

Event describes the event mask that was observed and the user data to be returned when one of the events occurs. It has this format to match the linux format to avoid extra copying/allocation when writing events to userspace.

type EventPoll

type EventPoll struct {
	fsutil.FilePipeSeek             `state:"zerovalue"`
	fsutil.FileNotDirReaddir        `state:"zerovalue"`
	fsutil.FileNoFsync              `state:"zerovalue"`
	fsutil.FileNoopFlush            `state:"zerovalue"`
	fsutil.FileNoIoctl              `state:"zerovalue"`
	fsutil.FileNoMMap               `state:"zerovalue"`
	fsutil.FileNoSplice             `state:"nosave"`
	fsutil.FileUseInodeUnstableAttr `state:"nosave"`

	// Wait queue is used to notify interested parties when the event poll
	// object itself becomes readable or writable.
	waiter.Queue `state:"zerovalue"`
	// contains filtered or unexported fields
}

EventPoll holds all the state associated with an event poll object, that is, collection of files to observe and their current state.

+stateify savable

func (*EventPoll) AddEntry

func (e *EventPoll) AddEntry(id FileIdentifier, flags EntryFlags, mask waiter.EventMask, data [2]int32) error

AddEntry adds a new file to the collection of files observed by e.

func (*EventPoll) Read

Read implements fs.FileOperations.Read.

func (*EventPoll) ReadEvents

func (e *EventPoll) ReadEvents(max int) []Event

ReadEvents returns up to max available events.

func (*EventPoll) Readiness

func (e *EventPoll) Readiness(mask waiter.EventMask) waiter.EventMask

Readiness determines if the event poll object is currently readable (i.e., if there are pending events for delivery).

func (*EventPoll) Release

func (e *EventPoll) Release()

Release implements fs.FileOperations.Release.

func (*EventPoll) RemoveEntry

func (e *EventPoll) RemoveEntry(id FileIdentifier) error

RemoveEntry a files from the collection of observed files.

func (*EventPoll) UnregisterEpollWaiters

func (e *EventPoll) UnregisterEpollWaiters()

UnregisterEpollWaiters removes the epoll waiter objects from the waiting queues. This is different from Release() as the file is not dereferenced.

func (*EventPoll) UpdateEntry

func (e *EventPoll) UpdateEntry(id FileIdentifier, flags EntryFlags, mask waiter.EventMask, data [2]int32) error

UpdateEntry updates the flags, mask and user data associated with a file that is already part of the collection of observed files.

func (*EventPoll) Write

Write implements fs.FileOperations.Write.

type FileIdentifier

type FileIdentifier struct {
	File *fs.File `state:"wait"`
	Fd   int32
}

FileIdentifier identifies a file. We cannot use just the FD because it could potentially be reassigned. We also cannot use just the file pointer because it is possible to have multiple entries for the same file object as long as they are created with different FDs (i.e., the FDs point to the same file).

+stateify savable

Jump to

Keyboard shortcuts

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