queue

package
v0.0.0-...-3e94386 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2018 License: MIT Imports: 1 Imported by: 2

Documentation

Overview

Package queue implements the heap interface in order to implement a request queue of distributed lock requests. The heap request queue is prioritized by timestamp.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mssg

type Mssg struct {
	Timestamp time.Time
	Node      string
	Replied   bool //to track whether the peer has replied to the request yet
}

Mssg represents the type being stored in the request queue heap.

type ReqHeap

type ReqHeap []*Mssg

ReqHeap is a (simple) type implementing the request queue heap. Len, Swap, and Less functions are used to implement the heap.

func (ReqHeap) Len

func (h ReqHeap) Len() int

Len returns the length of the heap.

func (ReqHeap) Less

func (h ReqHeap) Less(i, j int) bool

Less is used for comparing nodes when building and maintaining the heap.

func (*ReqHeap) Pop

func (h *ReqHeap) Pop() interface{}

Pop removes the oldest Mssg from the heap.

func (*ReqHeap) Push

func (h *ReqHeap) Push(x interface{})

Push adds a new Mssg into the heap.

func (ReqHeap) Swap

func (h ReqHeap) Swap(i, j int)

Swap is used for building and maintaining the heap.

Jump to

Keyboard shortcuts

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