package
module
Version:
v0.0.1
Opens a new window with list of versions in this module.
Published: Jan 17, 2023
License: MIT
Opens a new window with license information.
Imports: 1
Opens a new window with list of imports.
Imported by: 1
Opens a new window with list of known importers.
README
¶
gmx
Generic Mutex container types for Go, inspired by Rust's
Mutex and
RwLock.
It uses new language features introduced since go1.18:
-
generic type
-
generic interface
-
generic function
Documentation
¶
Generic Mutex container types for Go, inspired by Rust's Mutex and RwLock.
type Mutation[T any] func(*T)
Mutation represents mutable operation on a pointer
type Mutexer[T any] interface {
Do(Mutation[T])
Unwrap() T
}
Mutexer is implemented by Mx and RwMx
Generic Mutex container type
func Wrap[T any](x *T) *Mx[T]
Wrap a pointer into Mx
Do mutable operation on wrapped value guarded by sync.RWMutex
func (m *Mx[T]) Unwrap() T
Unwrap returns value references by the wrapped pointer
Generic Read-Write Mutex container type
Do mutable operation on wrapped value guarded by sync.RWMutex
func (m *RwMx[T]) Unwrap() T
Unwrap returns value references by the wrapped pointer
Source Files
¶
Directories
¶
Click to show internal directories.
Click to hide internal directories.