Skip to content

shettyh/tlock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TLock

Build

Simple Golang Lock with Timeout support.

Install

  • go get github.com/shettyh/tlock

How to use

// Create lock
tlock := tlock.New()

//blocking Lock/unlock
tlock.Lock()
defer tlock.Unlock()


// non-blocking lock/unlock
if tlock.TryLock() {
    defer tlock.Unlock()
    ...
}


// block lock/unlock with timeout
if tlock.TryLockWithTimeout(time.Seconds * 10 ) {
    defer tlock.Unlock()
    ...
}

For detailed example please check the examples folder