viewstate

package
v0.0.0-...-2a45ea8 Latest Latest
Warning

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

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

Documentation

Overview

Package viewstate allows to manage current active view number. It provides means for obtaining the current active view number, as well as to coordinate the process of changing its value according to the view-change mechanism.

There are two main values that represent the state of the view: 'current' and 'expected' view numbers. The values initially equal to zero and can only monotonically increase.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type State

type State interface {
	HoldView() (current, expected uint64, release func())
	AdvanceExpectedView(view uint64) (ok bool, release func())
	AdvanceCurrentView(view uint64) (ok bool, expected uint64, release func())
}

State defines operations on view state. All methods are safe to invoke concurrently.

HoldView method returns current and expected view numbers and defers view change. The returned values will denote the actual view state until the returned release function is invoked.

AdvanceExpectedView method synchronizes beginning of view change. If the supplied view number is greater than the expected view number then the latter is increased to match the supplied one. It returns true if the expected view number was updated. In that case, the current and expected view numbers will remain the same until the returned release function is invoked.

AdvanceCurrentView method synchronizes transition into a new view. If the supplied value is greater than the current view number then the latter is increased to match the supplied one. It returns true if the current view number was updated. In that case, the current and expected view numbers will remain the same, and the returned expected view number will denote the actual view state, until the returned release function is invoked.

func New

func New() State

New creates a new instance of the view state.

Directories

Path Synopsis
Package mock_viewstate is a generated GoMock package.
Package mock_viewstate is a generated GoMock package.

Jump to

Keyboard shortcuts

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