]> Cypherpunks repositories - gostls13.git/commit
runtime: make LockOSThread/UnlockOSThread nested
authorAustin Clements <austin@google.com>
Wed, 14 Jun 2017 15:46:35 +0000 (11:46 -0400)
committerAustin Clements <austin@google.com>
Thu, 5 Oct 2017 19:50:23 +0000 (19:50 +0000)
commitc85b12b5796c7efd4d8311253208b47449161361
tree71a145548a3253df3545e3206f5b2f0535f98f0c
parent555c16d8cbd8372c1f57beb059a23b56bf1e909f
runtime: make LockOSThread/UnlockOSThread nested

Currently, there is a single bit for LockOSThread, so two calls to
LockOSThread followed by one call to UnlockOSThread will unlock the
thread. There's evidence (#20458) that this is almost never what
people want or expect and it makes these APIs very hard to use
correctly or reliably.

Change this so LockOSThread/UnlockOSThread can be nested and the
calling goroutine will not be unwired until UnlockOSThread has been
called as many times as LockOSThread has. This should fix the vast
majority of incorrect uses while having no effect on the vast majority
of correct uses.

Fixes #20458.

Change-Id: I1464e5e9a0ea4208fbb83638ee9847f929a2bacb
Reviewed-on: https://go-review.googlesource.com/45752
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/runtime/export_test.go
src/runtime/proc.go
src/runtime/proc_test.go
src/runtime/runtime2.go