timedlist

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2024 License: MIT Imports: 5 Imported by: 0

README

Go Report Card Go Reference

TimedList

TimedList allows you to create a list of items that should be stored for a certain amount of time.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TimedEntry

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

func (TimedEntry) Less

func (t TimedEntry) Less(than llrb.Item) bool

func (TimedEntry) Value

func (t TimedEntry) Value() interface{}

Value returns the value of the entry

type TimedList

type TimedList struct {
	C chan interface{}
	// contains filtered or unexported fields
}

func NewTimedList

func NewTimedList() *TimedList

NewTimedList creates a new TimedList

func (*TimedList) Add

func (t *TimedList) Add(v interface{}, d time.Duration) (item *TimedEntry)

Add adds v to the list with duration d

It refreshes the timer if the new element will expire before the current timer

func (*TimedList) Drain

func (t *TimedList) Drain()

Drain drains the list into the channel

It calls stop after draining the list

func (*TimedList) Len

func (t *TimedList) Len() int

Len returns the number of elements in the list

func (*TimedList) Purge

func (t *TimedList) Purge()

Purge removes all elements from the list and then calls stop

func (*TimedList) Remove

func (t *TimedList) Remove(te *TimedEntry) (v interface{})

Remove removes te from the list.

It calls stop if the list is empty after removing the element.

It returns the value of the element removed.

Jump to

Keyboard shortcuts

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