queue

package
v0.2.2-buildfails Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2015 License: MIT Imports: 8 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChanQueue

type ChanQueue struct {
	Queue   PeerQueue
	EnqChan chan<- peer.ID
	DeqChan <-chan peer.ID
}

ChanQueue makes any PeerQueue synchronizable through channels.

func NewChanQueue

func NewChanQueue(ctx context.Context, pq PeerQueue) *ChanQueue

NewChanQueue creates a ChanQueue by wrapping pq.

type PeerQueue

type PeerQueue interface {

	// Len returns the number of items in PeerQueue
	Len() int

	// Enqueue adds this node to the queue.
	Enqueue(peer.ID)

	// Dequeue retrieves the highest (smallest int) priority node
	Dequeue() peer.ID
}

PeerQueue maintains a set of peers ordered according to a metric. Implementations of PeerQueue could order peers based on distances along a KeySpace, latency measurements, trustworthiness, reputation, etc.

func NewXORDistancePQ

func NewXORDistancePQ(fromKey u.Key) PeerQueue

NewXORDistancePQ returns a PeerQueue which maintains its peers sorted in terms of their distances to each other in an XORKeySpace (i.e. using XOR as a metric of distance).

Jump to

Keyboard shortcuts

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