model

package
v0.0.0-...-f2d3015 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const NanosecondsPerSecond = int64(time.Second / time.Nanosecond)

Variables

This section is empty.

Functions

This section is empty.

Types

type DataSinkBytes

type DataSinkBytes interface {
	EventSource
	// TryWrite attempts to write a series of bytes to a sink.
	// If TryWrite writes less than requested, the caller should assume it will not succeed in writing more until an
	// event is sent to the source's subscribers -- and even then, it's not guaranteed.
	TryWrite(from []byte) int
}

type DataSourceBytes

type DataSourceBytes interface {
	EventSource
	// TryRead attempts to read a series of bytes from a source.
	// If TryRead reads less than requested, the caller should assume it will not succeed in reading more until an
	// event is sent to the source's subscribers -- and even then, it's not guaranteed.
	TryRead(into []byte) int
}

type EventSource

type EventSource interface {
	Subscribe(callback func()) (cancel func())
}

type SimContext

type SimContext interface {
	Now() VirtualTime
	Rand() *rand.Rand
	SetTimer(expireAt VirtualTime, name string, callback func()) (cancel func())
	Later(name string, callback func()) (cancel func())
}

type VirtualTime

type VirtualTime int64
const TimeNever VirtualTime = -1
const TimeZero VirtualTime = 0

func FromNanoseconds

func FromNanoseconds(t uint64) (VirtualTime, bool)

func FromNanosecondsAssume

func FromNanosecondsAssume(t uint64) VirtualTime

func FromNanosecondsIgnore

func FromNanosecondsIgnore(t uint64) VirtualTime

func ParseTime

func ParseTime(s string) (VirtualTime, error)

func (VirtualTime) Add

func (t VirtualTime) Add(duration time.Duration) VirtualTime

func (VirtualTime) After

func (t VirtualTime) After(t2 VirtualTime) bool

func (VirtualTime) AtOrAfter

func (t VirtualTime) AtOrAfter(t2 VirtualTime) bool

func (VirtualTime) AtOrBefore

func (t VirtualTime) AtOrBefore(t2 VirtualTime) bool

func (VirtualTime) Before

func (t VirtualTime) Before(t2 VirtualTime) bool

func (VirtualTime) Nanoseconds

func (t VirtualTime) Nanoseconds() uint64

func (VirtualTime) Since

func (t VirtualTime) Since(base VirtualTime) time.Duration

func (VirtualTime) String

func (t VirtualTime) String() string

func (VirtualTime) TimeDistance

func (t VirtualTime) TimeDistance(t2 VirtualTime) time.Duration

func (VirtualTime) TimeExists

func (t VirtualTime) TimeExists() bool

Jump to

Keyboard shortcuts

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