Documentation
¶
Index ¶
Constants ¶
View Source
const CacheLineSize = unsafe.Sizeof(cpu.CacheLinePad{})
CacheLineSize is the size of a CPU cache line
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Slice ¶
type Slice[T any] struct { // Init is an optional callback for initializing the created item x. Init func(x *T) // contains filtered or unexported fields }
Slice allows goroutine-safe access to []*T items with automatic growth of the slice.
This is a replacement for [workersCount]*T where workersCount isn't known beforehand.
It also prevents from false sharing of the created T items on multi-CPU systems.
func (*Slice[T]) All ¶ added in v1.102.20
func (s *Slice[T]) All() []*T
All returns the underlying []*T.
The length of the returned slice equals to the max(workerID)+1 passed to s.Get(). It is guaranteed that all the items in the returned slice are non-nil.
It is unsafe calling this function when concurrent goroutines access s.
All() is relatively slow, so it shouldn't be called in hot paths.
Click to show internal directories.
Click to hide internal directories.