dial

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: Apache-2.0, UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Overview

Package dial contains an implementation of a thread-safe priority dial queue. The queue is sorted by dial items, time ascending. The behavior of the dial queue is the following:

- Peeking the dial queue will return the most urgent dial item, or nil if the queue is empty.

- Popping the dial queue will return the most urgent dial item or nil if the queue is empty. Popping removes the dial item.

- Push will push a new item to the dial queue, upon which the queue will find an adequate place for it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Item

type Item struct {
	Time    time.Time         // appropriate dial time
	Address *types.NetAddress // the dial address of the peer
}

Item is a single dial queue item, wrapping the approximately appropriate dial time, and the peer dial address

func (Item) Less

func (i Item) Less(item Item) bool

Less is the comparison method for the dial queue Item (time ascending)

type Queue

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

Queue is a time-sorted (ascending) dial queue

func NewQueue

func NewQueue() *Queue

NewQueue creates a new dial queue

func (*Queue) Has

func (q *Queue) Has(addr *types.NetAddress) bool

Has returns a flag indicating if the given address is in the dial queue

func (*Queue) Peek

func (q *Queue) Peek() *Item

Peek returns the first item in the dial queue, if any

func (*Queue) Pop

func (q *Queue) Pop() *Item

Pop removes an item from the dial queue, if any

func (*Queue) Push

func (q *Queue) Push(items ...Item)

Push adds new items to the dial queue

Jump to

Keyboard shortcuts

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