xact

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Xact

type Xact[T any] struct {
	// contains filtered or unexported fields
}

Xact represents a single in-memory transaction, to aid with separating calculations from their application.

func New

func New[T any](ptr *T) *Xact[T]

New returns a new transaction object (called Xact) operating on the given pointer

NOTE: Any copying is shallow -- if T contains pointers, any changes to the values behind those will NOT be delayed until (*Xact[T]).Commit().

func (*Xact[T]) Commit

func (x *Xact[T]) Commit()

Commit assigns the temporary value back to the original pointer that the Xact was created with

A transaction can be committed multiple times, if it's useful to reuse it.

func (*Xact[T]) Value

func (x *Xact[T]) Value() *T

Value returns a pointer to the temporary value stored in the Xact

The returned value can be freely modified; it will have no effect until the transaction is committed with Commit().

Jump to

Keyboard shortcuts

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