]> Cypherpunks.ru repositories - gostls13.git/commit
sync: add Mutex.TryLock, RWMutex.TryLock, RWMutex.TryRLock
authorRuss Cox <rsc@golang.org>
Thu, 13 May 2021 14:44:47 +0000 (10:44 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 29 Oct 2021 17:13:13 +0000 (17:13 +0000)
commit645d07819b2224ba4d759829443f7c6442162c69
tree3705bdb9d742fee07d0d356156ea511b257e0c25
parent3aecb3a8f7e1435c76003a20068c0208fd73649a
sync: add Mutex.TryLock, RWMutex.TryLock, RWMutex.TryRLock

Use of these functions is almost (but not) always a bad idea.

Very rarely they are necessary, and third-party implementations
(using a mutex and an atomic word, say) cannot integrate as well
with the race detector as implmentations in package sync itself.

Fixes #45435.

Change-Id: I0128ca48ef5e0a3b09c913f0f3a7ee5c56388000
Reviewed-on: https://go-review.googlesource.com/c/go/+/319769
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/sync/mutex.go
src/sync/mutex_test.go
src/sync/rwmutex.go
src/sync/rwmutex_test.go