]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: convert profbuf.eof to atomic type
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 17 Aug 2022 10:45:15 +0000 (17:45 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Thu, 18 Aug 2022 02:51:31 +0000 (02:51 +0000)
Updates #53821

Change-Id: I271faaedbf8b8efca5fc765496eaf45c94927edf
Reviewed-on: https://go-review.googlesource.com/c/go/+/423891
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
src/runtime/profbuf.go

index 5968c4ba7720dbba05cbdb937a94f1591d05f836..c579f214887cffb7c2c4681e07f21e56456dea7a 100644 (file)
@@ -89,7 +89,7 @@ type profBuf struct {
        r, w         profAtomic
        overflow     atomic.Uint64
        overflowTime atomic.Uint64
-       eof          uint32
+       eof          atomic.Uint32
 
        // immutable (excluding slice content)
        hdrsize uintptr
@@ -394,10 +394,10 @@ func (b *profBuf) write(tagPtr *unsafe.Pointer, now int64, hdr []uint64, stk []u
 // close signals that there will be no more writes on the buffer.
 // Once all the data has been read from the buffer, reads will return eof=true.
 func (b *profBuf) close() {
-       if atomic.Load(&b.eof) > 0 {
+       if b.eof.Load() > 0 {
                throw("runtime: profBuf already closed")
        }
-       atomic.Store(&b.eof, 1)
+       b.eof.Store(1)
        b.wakeupExtra()
 }
 
@@ -475,7 +475,7 @@ Read:
                        dst[2+b.hdrsize] = uint64(count)
                        return dst[:2+b.hdrsize+1], overflowTag[:1], false
                }
-               if atomic.Load(&b.eof) > 0 {
+               if b.eof.Load() > 0 {
                        // No data, no overflow, EOF set: done.
                        return nil, nil, true
                }