type spanSet … const spanSetBlockEntries … const spanSetInitSpineCap … type spanSetBlock … // push adds span s to buffer b. push is safe to call concurrently // with other push and pop operations. func (b *spanSet) push(s *mspan) { … } // pop removes and returns a span from buffer b, or nil if b is empty. // pop is safe to call concurrently with other pop and push operations. func (b *spanSet) pop() *mspan { … } // reset resets a spanSet which is empty. It will also clean up // any left over blocks. // // Throws if the buf is not empty. // // reset may not be called concurrently with any other operations // on the span set. func (b *spanSet) reset() { … } type atomicSpanSetSpinePointer … // Loads the spanSetSpinePointer and returns it. // // It has the same semantics as atomic.UnsafePointer. func (s *atomicSpanSetSpinePointer) Load() spanSetSpinePointer { … } // Stores the spanSetSpinePointer. // // It has the same semantics as [atomic.UnsafePointer]. func (s *atomicSpanSetSpinePointer) StoreNoWB(p spanSetSpinePointer) { … } type spanSetSpinePointer … // lookup returns &s[idx]. func (s spanSetSpinePointer) lookup(idx uintptr) *atomic.Pointer[spanSetBlock] { … } var spanSetBlockPool … type spanSetBlockAlloc … // alloc tries to grab a spanSetBlock out of the pool, and if it fails // persistentallocs a new one and returns it. func (p *spanSetBlockAlloc) alloc() *spanSetBlock { … } // free returns a spanSetBlock back to the pool. func (p *spanSetBlockAlloc) free(block *spanSetBlock) { … } type headTailIndex … // makeHeadTailIndex creates a headTailIndex value from a separate // head and tail. func makeHeadTailIndex(head, tail uint32) headTailIndex { … } // head returns the head of a headTailIndex value. func (h headTailIndex) head() uint32 { … } // tail returns the tail of a headTailIndex value. func (h headTailIndex) tail() uint32 { … } // split splits the headTailIndex value into its parts. func (h headTailIndex) split() (head uint32, tail uint32) { … } type atomicHeadTailIndex … // load atomically reads a headTailIndex value. func (h *atomicHeadTailIndex) load() headTailIndex { … } // cas atomically compares-and-swaps a headTailIndex value. func (h *atomicHeadTailIndex) cas(old, new headTailIndex) bool { … } // incHead atomically increments the head of a headTailIndex. func (h *atomicHeadTailIndex) incHead() headTailIndex { … } // decHead atomically decrements the head of a headTailIndex. func (h *atomicHeadTailIndex) decHead() headTailIndex { … } // incTail atomically increments the tail of a headTailIndex. func (h *atomicHeadTailIndex) incTail() headTailIndex { … } // reset clears the headTailIndex to (0, 0). func (h *atomicHeadTailIndex) reset() { … } type atomicMSpanPointer … // Load returns the *mspan. func (p *atomicMSpanPointer) Load() *mspan { … } // Store stores an *mspan. func (p *atomicMSpanPointer) StoreNoWB(s *mspan) { … }