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:
parent
9b6a55d791
commit
4df729f54b
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user