Skip to content

chappjc/trylock

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

trylock - TryLock implementation for Go

WARNING

Do NOT use this in production. This was never meant to be much more than an experiment.

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
}

About

TryLock for Go

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Go 100.0%