Categorygithub.com/chappjc/trylock
repositorypackage
1.0.0
Repository: https://github.com/chappjc/trylock.git
Documentation: pkg.go.dev

# README

trylock - TryLock implementation for Go

Build Status GoDoc

trylock uses unsafe, which is sorta "unsafe", but should work until sync.Mutex will change its layout (I hope it never will).

The original author of trylock is by LK4D4.

Usage

type LockedStruct struct {
	trylock.Mutex
}

storage := &LockedStruct{}

if storage.TryLock() {
	// do something with storage
} else {
	// return busy or use some logic for unavailable storage
}