lamport

package
v0.0.0-...-ddf849a Latest Latest
Warning

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

Go to latest
Published: May 15, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Observe

func Observe(t Time)

Observe ensures that the time past t by at least. Must be called when receiving a message from a remote machine to roughly synchronize clocks between processes.

Types

type Clock

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

Clock implements a lamport clock. The current time can be retrieved by calling Now. The Clock must be manually incremented either by calling Tick or Observe.

func (*Clock) Now

func (c *Clock) Now() Time

Now returns the current Time of c. The time is not changed.

func (*Clock) Observe

func (c *Clock) Observe(t Time)

Observe ensures that c's time is past t. Observe must be called when receiving a message from a remote machine that contains a Time, and is used to roughly synchronize clocks between machines.

func (*Clock) Tick

func (c *Clock) Tick() Time

Tick increases c's Time by 1 and returns the new value.

type Time

type Time uint64

Time is the value of a Clock.

func Now

func Now() Time

Now returns the current Time. The time will not be changed.

func Tick

func Tick() Time

Tick increases the current Time by 1 and returns it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳