Documentation
¶
Overview ¶
Package guarded makes locking discipline structural: a Guarded[T] owns both the mutex and the value it protects, so the value is reachable only through With/Get — there is no way to touch it outside the lock. The convention "fields below mu are guarded by mu" becomes a type.
Authored in G++ and distributed as generated Go — consumers never need the gpp toolchain.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Guarded ¶
type Guarded[T any] struct { // contains filtered or unexported fields }
Guarded is a mutex-owning cell. The zero value is usable when T's zero value is.
type RWGuarded ¶
type RWGuarded[T any] struct { // contains filtered or unexported fields }
RWGuarded is Guarded with reader/writer locking: RWith serializes against With/Set but not against other RWith calls.
func (*RWGuarded[T]) Get ¶
func (g *RWGuarded[T]) Get() T
Get returns a copy of the value taken under the read lock.
func (*RWGuarded[T]) RWith ¶
func (g *RWGuarded[T]) RWith(f func(T))
RWith runs f over the value under the read lock. f must not mutate through aliases it retains; the value must be treated as read-only.