• Austin Clements's avatar
    runtime: make LockOSThread/UnlockOSThread nested · c85b12b5
    Austin Clements authored
    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: 's avatarKeith Randall <khr@golang.org>
    c85b12b5
proc_test.go 15.3 KB