mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
don't use atomic operations to initialize refcounts
It's not necessary, as un-initialized refcounts haven't been shared across goroutines yet. This saves us a bunch of slow atomic operations. PiperOrigin-RevId: 536472388
This commit is contained in:
committed by
gVisor bot
parent
f4a4cde7dd
commit
08ff84c6e7
@@ -63,7 +63,9 @@ type Refs struct {
|
||||
// InitRefs initializes r with one reference and, if enabled, activates leak
|
||||
// checking.
|
||||
func (r *Refs) InitRefs() {
|
||||
r.refCount.Store(1)
|
||||
// We can use RacyStore because the refs can't be shared until after
|
||||
// InitRefs is called, and thus it's safe to use non-atomic operations.
|
||||
r.refCount.RacyStore(1)
|
||||
refs.Register(r)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user