]> Cypherpunks repositories - gostls13.git/commit
runtime: implement the spanSet data structure
authorMichael Anthony Knyszek <mknyszek@google.com>
Thu, 20 Feb 2020 21:28:02 +0000 (21:28 +0000)
committerMichael Knyszek <mknyszek@google.com>
Mon, 27 Apr 2020 18:16:07 +0000 (18:16 +0000)
commit9582b6e8fd1b278e670987c7689920888191b14f
tree914ae13001b3f7a167b51488d03342eaf2dbf524
parentd1798d5aa01501a6c7d0508441532321c90a7378
runtime: implement the spanSet data structure

This change implements the spanSet data structure which is based off of
the gcSweepBuf data structure. While the general idea is the same (one
has two of these which one switches between every GC cycle; one to push
to and one to pop from), there are some key differences.

Firstly, we never have a need to iterate over this data structure so
delete numBlocks and block. Secondly, we want to be able to pop from the
front of the structure concurrently with pushes to the back. As a result
we need to maintain both a head and a tail and this change introduces an
atomic headTail structure similar to the one used by sync.Pool. It also
implements popfirst in a similar way.

As a result of this headTail, we need to be able to explicitly reset the
length, head, and tail when it goes empty at the end of sweep
termination, so add a reset method.

Updates #37487.

Change-Id: I5b8ad290ec32d591e3c8c05e496c5627018074f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/221181
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
src/runtime/mspanset.go