mirror of
https://github.com/yudai/gotty.git
synced 2026-03-04 04:40:17 +01:00
Change to go1.6.1 and vendoring
This commit is contained in:
parent
b1c5226875
commit
a350994aa2
164 changed files with 17 additions and 1383 deletions
53
Godeps/_workspace/src/github.com/yudai/umutex/README.md
generated
vendored
53
Godeps/_workspace/src/github.com/yudai/umutex/README.md
generated
vendored
|
|
@ -1,53 +0,0 @@
|
|||
# Unblocking Mutex
|
||||
|
||||
This simple package provides unblocking mutexes for those who don't want to write many `select` clauses or get confused by numerous channels.
|
||||
|
||||
## Usage Example
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/yudai/umutex"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Create mutex
|
||||
mutex := umutex.New()
|
||||
|
||||
// First time, try should succeed
|
||||
if mutex.TryLock() {
|
||||
fmt.Println("SUCCESS")
|
||||
} else {
|
||||
fmt.Println("FAILURE")
|
||||
}
|
||||
|
||||
// Second time, try should fail as it's locked
|
||||
if mutex.TryLock() {
|
||||
fmt.Println("SUCCESS")
|
||||
} else {
|
||||
fmt.Println("FAILURE")
|
||||
}
|
||||
|
||||
// Unclock mutex
|
||||
mutex.Unlock()
|
||||
|
||||
// Third time, try should succeed again
|
||||
if mutex.TryLock() {
|
||||
fmt.Println("SUCCESS")
|
||||
} else {
|
||||
fmt.Println("FAILURE")
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The output is;
|
||||
|
||||
```sh
|
||||
SUCCESS
|
||||
FAILURE
|
||||
SUCCESS
|
||||
```
|
||||
|
||||
`ForceLock()` method is also availale for normal blocking lock.
|
||||
Loading…
Add table
Add a link
Reference in a new issue