Skip to content

A package that provides the key level mutex locking mechanism.

License

Notifications You must be signed in to change notification settings

sertangulveren/lockey

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What is Lockey

It is a simple key-based mutex locking package.

Install

go get github.com/sertangulveren/lockey

Usage

var lk = lockey.New()

//...

lk.Lock("greatKey")
defer lk.Unlock("greatKey")

// Do a concurrent job
myGreatFunc()
//...

Basic Example

var lk = lockey.New()

func main() {
    //...
    for i := 0; i < bigNumber; i++ {
        go increaseMyMoney(i)
    }   
    //...
}

func increaseMyMoney(i int) {
    lk.Lock("makeMeRich")
    defer lk.Unlock("makeMeRich")
    
    money+=i
    addTransaction(i)
    //...
}

About

A package that provides the key level mutex locking mechanism.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages