Source File
profbuf.go
Belonging Package
runtime
package runtime
import (
)
type profAtomic uint64
type profIndex uint64
const (
profReaderSleeping profIndex = 1 << 32 // reader is sleeping and must be woken up
profWriteExtra profIndex = 1 << 33 // overflow or eof waiting
)
func ( *profAtomic) () profIndex {
return profIndex(atomic.Load64((*uint64)()))
}
func ( *profAtomic) ( profIndex) {
atomic.Store64((*uint64)(), uint64())
}
func ( *profAtomic) (, profIndex) bool {
return atomic.Cas64((*uint64)(), uint64(), uint64())
}
func ( profIndex) () uint32 {
return uint32()
}
func ( profIndex) () uint32 {
return uint32( >> 34)
}
.incrementOverflow()
.wakeupExtra()
return
}
if &profReaderSleeping != 0 {
notewakeup(&.wait)
}
break
}
}
func ( *profBuf) () {
for {
:= .w.load()
:= | profWriteExtra
if !.w.cas(, ) {
continue
}
if &profReaderSleeping != 0 {
notewakeup(&.wait)
}
break
}
}
type profBufReadMode int
const (
profBufBlocking profBufReadMode = iota
profBufNonBlocking
)
var overflowTag [1]unsafe.Pointer // always nil
func ( *profBuf) ( profBufReadMode) ( []uint64, []unsafe.Pointer, bool) {
if == nil {
return nil, nil, true
}
:= .rNext
, := .takeOverflow()
goto
.w.cas(, &^profWriteExtra)
goto
}
if == profBufNonBlocking {
return nil, nil, false
}
if !.w.cas(, |profReaderSleeping) {
goto
.rNext = .addCountsAndClearFlags(+, )
raceacquire(unsafe.Pointer(&labelSync))
}
return [:], [:], false
![]() |
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. |