Source File
pool.go
Belonging Package
sync
package sync
import (
)
New func() interface{}
}
type poolLocalInternal struct {
private interface{} // Can be used only by the respective P.
shared poolChain // Local P can pushHead/popHead; any P can popTail.
}
type poolLocal struct {
poolLocalInternal
pad [128 - unsafe.Sizeof(poolLocalInternal{})%128]byte
}
func () uint32
var poolRaceHash [128]uint64
:= runtime_LoadAcquintptr(&.localSize) // load-acquire
= atomic.LoadUintptr(&.victimSize)
if uintptr() >= {
return nil
}
= .victim
:= indexLocal(, )
if := .private; != nil {
.private = nil
return
}
for := 0; < int(); ++ {
:= indexLocal(, (+)%int())
if , := .shared.popTail(); != nil {
return
}
}
atomic.StoreUintptr(&.victimSize, 0)
return nil
}
:= runtime_LoadAcquintptr(&.localSize) // load-acquire
:= .local // load-consume
if uintptr() < {
return indexLocal(, ),
}
return .pinSlow()
}
runtime_procUnpin()
allPoolsMu.Lock()
defer allPoolsMu.Unlock()
:= runtime.GOMAXPROCS(0)
:= make([]poolLocal, )
atomic.StorePointer(&.local, unsafe.Pointer(&[0])) // store-release
runtime_StoreReluintptr(&.localSize, uintptr()) // store-release
return &[],
}
for , := range oldPools {
.victim = nil
.victimSize = 0
}
func ( func())
func () int
func ()
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |