umutex:Golang解锁互斥锁
解除互斥锁
这个简单的程序包为那些不想编写很多select子句或不想被众多渠道弄糊涂的人提供了无阻塞的互斥锁。
使用范例
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