From 4df729f54bb0e67c42eba464220dc6d98c9b0320 Mon Sep 17 00:00:00 2001 From: Xargin Date: Fri, 3 Aug 2018 14:29:47 +0800 Subject: [PATCH] change unlock logic in trylock example --- ch6-cloud/ch6-08-lock.md | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/ch6-cloud/ch6-08-lock.md b/ch6-cloud/ch6-08-lock.md index b24715b..6e5194a 100644 --- a/ch6-cloud/ch6-08-lock.md +++ b/ch6-cloud/ch6-08-lock.md @@ -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