connections

package
v0.0.0-...-798ae07 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2023 License: GPL-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package list implements a doubly linked list.

To iterate over a list (where l is a *List):

for e := l.Front(); e != nil; e = e.Next() {
	// do something with e.Value
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnInterface

type ConnInterface interface {
}

type Element

type Element struct {

	// The value stored with this element.
	Value *rtnetlink.Conn
	// contains filtered or unexported fields
}

Element is an element of a linked list.

func (*Element) Next

func (e *Element) Next() *Element

Next returns the next list element or nil.

func (*Element) Prev

func (e *Element) Prev() *Element

Prev returns the previous list element or nil.

type List

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

List represents a doubly linked list. The zero value for List is an empty list ready to use.

func NewList

func NewList() *List

New returns an initialized list.

func (*List) Back

func (l *List) Back() *Element

Back returns the last element of list l or nil if the list is empty.

func (*List) Front

func (l *List) Front() *Element

Front returns the first element of list l or nil if the list is empty.

func (*List) Init

func (l *List) Init() *List

Init initializes or clears list l.

func (*List) InsertAfter

func (l *List) InsertAfter(v *rtnetlink.Conn, mark *Element) *Element

InsertAfter inserts a new element e with value v immediately after mark and returns e. If mark is not an element of l, the list is not modified. The mark must not be nil.

func (*List) InsertBefore

func (l *List) InsertBefore(v *rtnetlink.Conn, mark *Element) *Element

InsertBefore inserts a new element e with value v immediately before mark and returns e. If mark is not an element of l, the list is not modified. The mark must not be nil.

func (*List) Len

func (l *List) Len() int

Len returns the number of elements of list l. The complexity is O(1).

func (*List) MoveAfter

func (l *List) MoveAfter(e, mark *Element)

MoveAfter moves element e to its new position after mark. If e or mark is not an element of l, or e == mark, the list is not modified. The element and mark must not be nil.

func (*List) MoveBefore

func (l *List) MoveBefore(e, mark *Element)

MoveBefore moves element e to its new position before mark. If e or mark is not an element of l, or e == mark, the list is not modified. The element and mark must not be nil.

func (*List) MoveToBack

func (l *List) MoveToBack(e *Element)

MoveToBack moves element e to the back of list l. If e is not an element of l, the list is not modified. The element must not be nil.

func (*List) MoveToFront

func (l *List) MoveToFront(e *Element)

MoveToFront moves element e to the front of list l. If e is not an element of l, the list is not modified. The element must not be nil.

func (*List) PushBack

func (l *List) PushBack(v *rtnetlink.Conn) *Element

PushBack inserts a new element e with value v at the back of list l and returns e.

func (*List) PushBackList

func (l *List) PushBackList(other *List)

PushBackList inserts a copy of another list at the back of list l. The lists l and other may be the same. They must not be nil.

func (*List) PushFront

func (l *List) PushFront(v *rtnetlink.Conn) *Element

PushFront inserts a new element e with value v at the front of list l and returns e.

func (*List) PushFrontList

func (l *List) PushFrontList(other *List)

PushFrontList inserts a copy of another list at the front of list l. The lists l and other may be the same. They must not be nil.

func (*List) Remove

func (l *List) Remove(e *Element) *rtnetlink.Conn

Remove removes e from l if e is an element of list l. It returns the element value e.Value. The element must not be nil.

type NetLinkConnectionPool

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

Internal management interface to cache/queue netlink connections to the kernel asynchronously, for better performance on the API side. The interface asynchronously builds up a few queued connections at any one time, and then

var (
	NetlinkPool *NetLinkConnectionPool
)

func NewConnPool

func NewConnPool(n int) *NetLinkConnectionPool

func (*NetLinkConnectionPool) GetConn

func (conn *NetLinkConnectionPool) GetConn() (*rtnetlink.Conn, error)

Callers should use method to acquire a new connection fd to use for their operations.

func (*NetLinkConnectionPool) ReturnConn

func (conn *NetLinkConnectionPool) ReturnConn(in *rtnetlink.Conn)

Callers should "return" file descriptor to pool after being completing tasks with connection. Connections can be recycled internally or thrown out if the number of connections is bigger than the number of static connections that are requested for this pool.

func (*NetLinkConnectionPool) StartManager

func (conn *NetLinkConnectionPool) StartManager()

Manager thread will spin up connections asynchronously.

func (*NetLinkConnectionPool) UpdateQueueSize

func (conn *NetLinkConnectionPool) UpdateQueueSize(n int) error

Jump to

Keyboard shortcuts

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