Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ooopsnake/timed_mutex
Golang time mutex
https://github.com/ooopsnake/timed_mutex
mutex timeout
Last synced: 3 days ago
JSON representation
Golang time mutex
- Host: GitHub
- URL: https://github.com/ooopsnake/timed_mutex
- Owner: ooopSnake
- License: mit
- Created: 2019-11-10T13:33:17.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-11-11T01:38:03.000Z (about 5 years ago)
- Last Synced: 2024-11-21T01:12:10.361Z (2 months ago)
- Topics: mutex, timeout
- Language: Go
- Homepage:
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# timed_mutex
![go report](https://goreportcard.com/badge/github.com/ooopSnake/timed_mutex)
![license](https://img.shields.io/badge/license-MIT-brightgreen.svg)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/ooopSnake/timed_mutex)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat)](https://github.com/ooopSnake/timed_mutex/pulls)
[![Ask Me Anything !](https://img.shields.io/badge/Ask%20me-anything-1abc9c.svg)](https://github.com/ooopSnake/timed_mutex/issues)## Usage
```go
import "github.com/ooopSnake/timed_mutex"
```## Overview
### 📌 Lock()
acquire a lock,block until lock obtained
### 📌 UnLock()
release lock
### 📌 TryLock() (locked bool)
try acquire a lock, `true` if lock obtained otherwise return `false ` immediately.
### 📌 TryLockTimeout(t time.Duration) (locked bool)
try acquire a lock in specified duration, `true` if lock obtained.
return `false` if the mutex still unavailable until specified time point has been reached.
## Getting Started
init lock 😏
```go
locker := timed_mutex.New()
```unlock 😐
```go
locker.UnLock()
```direct lock 😐
```go
locker.Lock()
```trylock 😎
```go
locked := locker.TryLock()
```trylock with timeout 😎
```go
locked := locker.TryLockTimeout(time.Second*5)
```## License
Released under the [MIT License](https://github.com/ooopSnake/timed_mutex/blob/master/LICENSE)