https://github.com/shettyh/tlock
Golang Lock with Timeout
https://github.com/shettyh/tlock
go mutex-lock timeout
Last synced: 5 months ago
JSON representation
Golang Lock with Timeout
- Host: GitHub
- URL: https://github.com/shettyh/tlock
- Owner: shettyh
- License: apache-2.0
- Created: 2020-04-29T04:01:33.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-11-24T02:41:02.000Z (over 5 years ago)
- Last Synced: 2023-07-28T12:59:14.048Z (almost 3 years ago)
- Topics: go, mutex-lock, timeout
- Language: Go
- Size: 12.7 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TLock

Simple Golang Lock with Timeout support.
## Install
- `go get github.com/shettyh/tlock`
## How to use
```go
// 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