lamport

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2022 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

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

Clock is a thread safe implementation of a lamport clock. It uses efficient atomic operations for all of its functions, falling back to a heavy lock only if there are enough CAS failures.

func NewClock

func NewClock() Clock

NewClock create a new clock with the value 1. Value 0 is considered as invalid.

func NewClockWithTime

func NewClockWithTime(time uint64) Clock

NewClockWithTime create a new clock with a value.

func (*Clock) Increment

func (l *Clock) Increment() Time

Increment is used to return the value of the lamport clock and increment it afterwards

func (*Clock) Time

func (l *Clock) Time() Time

Time is used to return the current value of the lamport clock

func (*Clock) Witness

func (l *Clock) Witness(v Time)

Witness is called to update our local clock if necessary after witnessing a clock value received from another process

type Persisted

type Persisted struct {
	Clock
	// contains filtered or unexported fields
}

func LoadPersisted

func LoadPersisted(filePath string) (*Persisted, error)

LoadPersisted load a persisted Lamport clock from a file

func NewPersisted

func NewPersisted(filePath string) (*Persisted, error)

NewPersisted create a new persisted Lamport clock

func (*Persisted) Increment

func (c *Persisted) Increment() (Time, error)

Increment is used to return the value of the lamport clock and increment it afterwards

func (*Persisted) Witness

func (c *Persisted) Witness(time Time) error

Witness is called to update our local clock if necessary after witnessing a clock value received from another process

func (*Persisted) Write

func (c *Persisted) Write() error

type Time

type Time uint64

Time is the value of a Clock.

Jump to

Keyboard shortcuts

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