gmx

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2025 License: MIT Imports: 1 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

gmx

go.dev reference License Ask DeepWiki

Generic Mutex container types for Go, inspired by Rust's Mutex and RwLock.

It uses new language features introduced since go1.18:

Documentation

Overview

Generic Mutex container types for Go, inspired by Rust's Mutex and RwLock.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mutation added in v0.0.1

type Mutation[T any] func(*T)

Mutation represents mutable operation on a pointer

type Mutexer added in v0.0.1

type Mutexer[T any] interface {
	// Mutate inner value
	Mut(Mutation[T])
	// Get inner value
	Get() T
}

Mutexer is implemented by Mx and RwMx

type Mx

type Mx[T any] struct {
	*sync.Mutex
	// contains filtered or unexported fields
}

Generic Mutex container type

func Wrap

func Wrap[T any](x *T) *Mx[T]

Wrap a pointer into Mx

func (*Mx[T]) Get added in v0.0.2

func (m *Mx[T]) Get() T

Get value referenced by the wrapped pointer

func (*Mx[T]) Mut added in v0.0.2

func (m *Mx[T]) Mut(op Mutation[T])

Mutate wrapped value guarded by sync.RWMutex

type RwMx

type RwMx[T any] struct {
	*sync.RWMutex
	// contains filtered or unexported fields
}

Generic Read-Write Mutex container type

func RwWrap

func RwWrap[T any](x *T) *RwMx[T]

Wrap a pointer into RwMx

func (*RwMx[T]) Get added in v0.0.2

func (m *RwMx[T]) Get() T

Get value referenced by the wrapped pointer

func (*RwMx[T]) Mut added in v0.0.2

func (m *RwMx[T]) Mut(op Mutation[T])

Mutate wrapped value guarded by sync.RWMutex

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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