Documentation
¶
Index ¶
- func Apply[T any](ctx context.Context, cell Cell[T], maxAttempts int, fn func(T) (T, error)) error
- func CopyBytes(dst *[]byte, src []byte)
- func DefaultCopy[T any](dst *T, src T)
- func DefaultEquals[T comparable](a, b T) bool
- func EqualBytes(a, b []byte) bool
- func IsErrCASMaxAttempts(err error) bool
- func IsErrTooLarge(err error) bool
- func Load[T any](ctx context.Context, cell Cell[T]) (ret T, _ error)
- type BytesCell
- type BytesCellBase
- type Cached
- type Cell
- type Derived
- type DerivedParams
- type ErrCASMaxAttempts
- type ErrTooLarge
- type MemBytes
- type MemCell
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
Apply attempts to do a CAS on the cell by applying fn to the current value to get the next value.
func DefaultCopy ¶
func DefaultCopy[T any](dst *T, src T)
func DefaultEquals ¶
func DefaultEquals[T comparable](a, b T) bool
func EqualBytes ¶
func IsErrCASMaxAttempts ¶
func IsErrTooLarge ¶
Types ¶
type BytesCellBase ¶
type BytesCellBase struct{}
BytesCellBase provides Equals, and Copy methods. It is intended to be composed in implementations of BytesCell
func (BytesCellBase) Copy ¶
func (BytesCellBase) Copy(dst *[]byte, src []byte)
func (BytesCellBase) Equals ¶
func (BytesCellBase) Equals(a, b []byte) bool
type Cached ¶
type Cached[T any] struct { // contains filtered or unexported fields }
func (*Cached[T]) Invalidate ¶
func (c *Cached[T]) Invalidate()
type Cell ¶
type Cell[T any] interface { // CAS sets the contents of the cell to next, IFF prev equals the cell contents. // returns whether or not the swap was successful, the actual value in the cell, or an error // if err != nil then success must be false. // the swap failing is not considered an error. CAS(ctx context.Context, actual *T, prev, next T) (success bool, err error) // Load retrieves the contents of the cell, and writes them to buf. // If err != nil the data returned is invalid. // If err == nil, n will be the number of bytes written Load(ctx context.Context, dst *T) error // Equals is the equality function used by the cell. Equals(a, b T) bool // Copy is the function used to copy values in and out of the cell. Copy(dst *T, src T) }
Cell is a compare-and-swap cell
type Derived ¶
type Derived[X, Y any] struct { // contains filtered or unexported fields }
func NewDerived ¶
func NewDerived[X, Y any](params DerivedParams[X, Y]) *Derived[X, Y]
type DerivedParams ¶
type ErrCASMaxAttempts ¶
type ErrCASMaxAttempts struct{}
func (ErrCASMaxAttempts) Error ¶
func (e ErrCASMaxAttempts) Error() string
type ErrTooLarge ¶
type ErrTooLarge struct{}
ErrTooLarge is returned from BytesCells when the object is too large to store
func (ErrTooLarge) Error ¶
func (e ErrTooLarge) Error() string
type MemBytes ¶
func NewMemBytes ¶
Click to show internal directories.
Click to hide internal directories.