Skip to content

Latest commit

 

History

History
35 lines (24 loc) · 561 Bytes

README.md

File metadata and controls

35 lines (24 loc) · 561 Bytes

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