Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

DmitriyMV/trylock

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

trylock - TryLock implementation for Go

Build Status GoDoc Coverage Status

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
}

About

TryLock for Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%