mirror of
https://github.com/golang/go
synced 2024-09-15 22:20:06 +00:00
runtime: convert profbuf.overflowTime to atomic type
Updates #53821 Change-Id: I916549d831f84d4f1439433aea6a61ff5301d80c Reviewed-on: https://go-review.googlesource.com/c/go/+/423890 Reviewed-by: Keith Randall <khr@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
parent
c3c10f5d67
commit
04d3d6bf48
|
@ -88,7 +88,7 @@ type profBuf struct {
|
|||
// accessed atomically
|
||||
r, w profAtomic
|
||||
overflow atomic.Uint64
|
||||
overflowTime uint64
|
||||
overflowTime atomic.Uint64
|
||||
eof uint32
|
||||
|
||||
// immutable (excluding slice content)
|
||||
|
@ -158,7 +158,7 @@ func (b *profBuf) hasOverflow() bool {
|
|||
// When called by the reader, it is racing against incrementOverflow.
|
||||
func (b *profBuf) takeOverflow() (count uint32, time uint64) {
|
||||
overflow := b.overflow.Load()
|
||||
time = atomic.Load64(&b.overflowTime)
|
||||
time = b.overflowTime.Load()
|
||||
for {
|
||||
count = uint32(overflow)
|
||||
if count == 0 {
|
||||
|
@ -170,7 +170,7 @@ func (b *profBuf) takeOverflow() (count uint32, time uint64) {
|
|||
break
|
||||
}
|
||||
overflow = b.overflow.Load()
|
||||
time = atomic.Load64(&b.overflowTime)
|
||||
time = b.overflowTime.Load()
|
||||
}
|
||||
return uint32(overflow), time
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ func (b *profBuf) incrementOverflow(now int64) {
|
|||
// We need to set overflowTime if we're incrementing b.overflow from 0.
|
||||
if uint32(overflow) == 0 {
|
||||
// Store overflowTime first so it's always available when overflow != 0.
|
||||
atomic.Store64(&b.overflowTime, uint64(now))
|
||||
b.overflowTime.Store(uint64(now))
|
||||
b.overflow.Store((((overflow >> 32) + 1) << 32) + 1)
|
||||
break
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue