repositorypackage
0.0.0-20191027065348-ff7e133a5c54
Repository: https://github.com/lk4d4/trylock.git
Documentation: pkg.go.dev
# README
trylock - TryLock implementation for Go
trylock uses unsafe, which is sorta "unsafe", but should work until sync.Mutex
will change its layout (I hope it never will).
Usage
type LockedStruct struct {
mu trylock.Mutex
}
storage := &LockedStruct{}
if storage.mu.TryLock() {
// do something with storage
} else {
// return busy or use some logic for unavailable storage
}