mirror of
https://github.com/chai2010/advanced-go-programming-book.git
synced 2025-05-24 12:32:21 +00:00
change unlock logic in trylock example
This commit is contained in:
parent
9b6a55d791
commit
4df729f54b
@ -102,14 +102,8 @@ func (l Lock) Lock() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Unlock , Unlock the try lock
|
// Unlock , Unlock the try lock
|
||||||
func (l Lock) Unlock() bool {
|
func (l Lock) Unlock() {
|
||||||
unlockResult := false
|
l.c <- struct{}{}
|
||||||
select {
|
|
||||||
case l.c <- struct{}{}:
|
|
||||||
unlockResult = true
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
return unlockResult
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var counter int
|
var counter int
|
||||||
|
Loading…
x
Reference in New Issue
Block a user