1
0
mirror of https://github.com/chai2010/advanced-go-programming-book.git synced 2025-05-24 20:52:22 +00:00

change unlock logic in trylock example

This commit is contained in:
Xargin 2018-08-03 14:29:47 +08:00
parent 9b6a55d791
commit 4df729f54b

View File

@ -102,14 +102,8 @@ func (l Lock) Lock() bool {
}
// Unlock , Unlock the try lock
func (l Lock) Unlock() bool {
unlockResult := false
select {
case l.c <- struct{}{}:
unlockResult = true
default:
}
return unlockResult
func (l Lock) Unlock() {
l.c <- struct{}{}
}
var counter int