Skip to content
/ mutex Public

๐Ÿ” in-memory mutex able to unlock with given token

License

Notifications You must be signed in to change notification settings

LPX3F8/mutex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

2 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

mutex

๐Ÿ” in-memory mutex able to unlock with given token

Install

go get -u github.com/LPX3F8/mutex

Example

import "github.com/LPX3F8/mutex"

func main() {
	tm := mutex.NewTokenMutex()
	tk := tm.Lock()         // return a string token, default a uuid
	tm.TryLock()            // return false, cause the mutex been locked
	tm.TryLockWithToken(tk) // return ture, cause the same token
	tm.LockWithToken(tk)    // return same token and will not block the process.
	tm.Unlock("fake" + tk)  // return false, cause token is wrong
	tm.Unlock(tk)           // return ture
}

About

๐Ÿ” in-memory mutex able to unlock with given token

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages