diff options
author | Austin Clements <austin@google.com> | 2018-09-25 17:41:11 -0400 |
---|---|---|
committer | Austin Clements <austin@google.com> | 2018-10-09 18:32:08 +0000 |
commit | 007e8a2fbda83e8863f7dda5632a100928318019 (patch) | |
tree | e4165bebceec6b744056e0fa01f3649172cf8e64 /src/runtime/mgcsweep.go | |
parent | f3bb4cbfd5a02b14a8660aa7e6a08801bcb9fbaf (diff) | |
download | go-007e8a2fbda83e8863f7dda5632a100928318019.tar.gz go-007e8a2fbda83e8863f7dda5632a100928318019.zip |
runtime: rename gosweepdone to isSweepDone and document better
gosweepdone is another anachronism from the time when the sweeper was
implemented in C. Rename it to "isSweepDone" for the modern era.
Change-Id: I8472aa6f52478459c3f2edc8a4b2761e73c4c2dd
Reviewed-on: https://go-review.googlesource.com/c/138658
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/runtime/mgcsweep.go')
-rw-r--r-- | src/runtime/mgcsweep.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/runtime/mgcsweep.go b/src/runtime/mgcsweep.go index 35b717ca9b..627a6a023f 100644 --- a/src/runtime/mgcsweep.go +++ b/src/runtime/mgcsweep.go @@ -60,7 +60,7 @@ func bgsweep(c chan int) { Gosched() } lock(&sweep.lock) - if !gosweepdone() { + if !isSweepDone() { // This can happen if a GC runs between // gosweepone returning ^0 above // and the lock being acquired. @@ -134,8 +134,13 @@ func sweepone() uintptr { return npages } -//go:nowritebarrier -func gosweepdone() bool { +// isSweepDone reports whether all spans are swept or currently being swept. +// +// Note that this condition may transition from false to true at any +// time as the sweeper runs. It may transition from true to false if a +// GC runs; to prevent that the caller must be non-preemptible or must +// somehow block GC progress. +func isSweepDone() bool { return mheap_.sweepdone != 0 } |