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.