fdmap

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package fdmap maps OS descriptors to connection objects using the cheapest synchronization available on each platform.

Index

Constants

View Source
const UseSingleInstance = true

Unix fds are small integers, so all event loops can share one direct index.

Variables

View Source
var ErrOutOfRange = errors.New("fdmap: descriptor out of range")
View Source
var MaxOpenFiles = maxOpenFilesCeiling

MaxOpenFiles covers the conventional Unix per-process fd ceiling. It is reduced to the process soft limit during initialization when necessary.

Functions

This section is empty.

Types

type Map

type Map[V any] struct {
	// contains filtered or unexported fields
}

Map is an atomic direct-index table shared by Unix event loops. Deletion must be published before a descriptor is closed because the kernel may reuse its integer immediately.

func NewMap

func NewMap[V any]() *Map[V]

NewMap returns an empty descriptor table; segments allocate with the descriptors published into them.

func (*Map[V]) Clear

func (m *Map[V]) Clear()

Clear atomically removes every descriptor entry.

func (*Map[V]) Delete

func (m *Map[V]) Delete(k int)

Delete atomically unpublishes descriptor k.

func (*Map[V]) DeleteValue added in v1.6.0

func (m *Map[V]) DeleteValue(k int, v *V)

DeleteValue removes k only while it still maps to v, so a holder that lost the slot to another value leaves that value in place.

func (*Map[V]) Get

func (m *Map[V]) Get(k int) *V

Get atomically resolves descriptor k, or returns nil when absent.

func (*Map[V]) Put

func (m *Map[V]) Put(k int, v *V) error

Put atomically publishes v at descriptor k.

func (*Map[V]) Range

func (m *Map[V]) Range() iter.Seq2[int, *V]

Range visits a weakly consistent view of live descriptors without locking producers. Callers may delete the yielded entry.

Jump to

Keyboard shortcuts

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