mirror of
https://github.com/golang/go
synced 2024-11-22 19:24:59 -07:00
sync/atomic: rename "ifaceWords" to "efaceWords"
Rename "ifaceWords" to "efaceWords", since we are defining an empty interface. Change-Id: I7151fb730a081a800e6dd28bcba831787ee9d6a2 Reviewed-on: https://go-review.googlesource.com/c/go/+/432815 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Run-TryBot: hopehook <hopehook@golangcn.org> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
parent
bf0a1ffbe2
commit
b78b84cd23
@ -17,8 +17,8 @@ type Value struct {
|
|||||||
v any
|
v any
|
||||||
}
|
}
|
||||||
|
|
||||||
// ifaceWords is interface{} internal representation.
|
// efaceWords is interface{} internal representation.
|
||||||
type ifaceWords struct {
|
type efaceWords struct {
|
||||||
typ unsafe.Pointer
|
typ unsafe.Pointer
|
||||||
data unsafe.Pointer
|
data unsafe.Pointer
|
||||||
}
|
}
|
||||||
@ -26,14 +26,14 @@ type ifaceWords struct {
|
|||||||
// Load returns the value set by the most recent Store.
|
// Load returns the value set by the most recent Store.
|
||||||
// It returns nil if there has been no call to Store for this Value.
|
// It returns nil if there has been no call to Store for this Value.
|
||||||
func (v *Value) Load() (val any) {
|
func (v *Value) Load() (val any) {
|
||||||
vp := (*ifaceWords)(unsafe.Pointer(v))
|
vp := (*efaceWords)(unsafe.Pointer(v))
|
||||||
typ := LoadPointer(&vp.typ)
|
typ := LoadPointer(&vp.typ)
|
||||||
if typ == nil || typ == unsafe.Pointer(&firstStoreInProgress) {
|
if typ == nil || typ == unsafe.Pointer(&firstStoreInProgress) {
|
||||||
// First store not yet completed.
|
// First store not yet completed.
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
data := LoadPointer(&vp.data)
|
data := LoadPointer(&vp.data)
|
||||||
vlp := (*ifaceWords)(unsafe.Pointer(&val))
|
vlp := (*efaceWords)(unsafe.Pointer(&val))
|
||||||
vlp.typ = typ
|
vlp.typ = typ
|
||||||
vlp.data = data
|
vlp.data = data
|
||||||
return
|
return
|
||||||
@ -48,8 +48,8 @@ func (v *Value) Store(val any) {
|
|||||||
if val == nil {
|
if val == nil {
|
||||||
panic("sync/atomic: store of nil value into Value")
|
panic("sync/atomic: store of nil value into Value")
|
||||||
}
|
}
|
||||||
vp := (*ifaceWords)(unsafe.Pointer(v))
|
vp := (*efaceWords)(unsafe.Pointer(v))
|
||||||
vlp := (*ifaceWords)(unsafe.Pointer(&val))
|
vlp := (*efaceWords)(unsafe.Pointer(&val))
|
||||||
for {
|
for {
|
||||||
typ := LoadPointer(&vp.typ)
|
typ := LoadPointer(&vp.typ)
|
||||||
if typ == nil {
|
if typ == nil {
|
||||||
@ -91,8 +91,8 @@ func (v *Value) Swap(new any) (old any) {
|
|||||||
if new == nil {
|
if new == nil {
|
||||||
panic("sync/atomic: swap of nil value into Value")
|
panic("sync/atomic: swap of nil value into Value")
|
||||||
}
|
}
|
||||||
vp := (*ifaceWords)(unsafe.Pointer(v))
|
vp := (*efaceWords)(unsafe.Pointer(v))
|
||||||
np := (*ifaceWords)(unsafe.Pointer(&new))
|
np := (*efaceWords)(unsafe.Pointer(&new))
|
||||||
for {
|
for {
|
||||||
typ := LoadPointer(&vp.typ)
|
typ := LoadPointer(&vp.typ)
|
||||||
if typ == nil {
|
if typ == nil {
|
||||||
@ -121,7 +121,7 @@ func (v *Value) Swap(new any) (old any) {
|
|||||||
if typ != np.typ {
|
if typ != np.typ {
|
||||||
panic("sync/atomic: swap of inconsistently typed value into Value")
|
panic("sync/atomic: swap of inconsistently typed value into Value")
|
||||||
}
|
}
|
||||||
op := (*ifaceWords)(unsafe.Pointer(&old))
|
op := (*efaceWords)(unsafe.Pointer(&old))
|
||||||
op.typ, op.data = np.typ, SwapPointer(&vp.data, np.data)
|
op.typ, op.data = np.typ, SwapPointer(&vp.data, np.data)
|
||||||
return old
|
return old
|
||||||
}
|
}
|
||||||
@ -136,9 +136,9 @@ func (v *Value) CompareAndSwap(old, new any) (swapped bool) {
|
|||||||
if new == nil {
|
if new == nil {
|
||||||
panic("sync/atomic: compare and swap of nil value into Value")
|
panic("sync/atomic: compare and swap of nil value into Value")
|
||||||
}
|
}
|
||||||
vp := (*ifaceWords)(unsafe.Pointer(v))
|
vp := (*efaceWords)(unsafe.Pointer(v))
|
||||||
np := (*ifaceWords)(unsafe.Pointer(&new))
|
np := (*efaceWords)(unsafe.Pointer(&new))
|
||||||
op := (*ifaceWords)(unsafe.Pointer(&old))
|
op := (*efaceWords)(unsafe.Pointer(&old))
|
||||||
if op.typ != nil && np.typ != op.typ {
|
if op.typ != nil && np.typ != op.typ {
|
||||||
panic("sync/atomic: compare and swap of inconsistently typed values")
|
panic("sync/atomic: compare and swap of inconsistently typed values")
|
||||||
}
|
}
|
||||||
@ -180,8 +180,8 @@ func (v *Value) CompareAndSwap(old, new any) (swapped bool) {
|
|||||||
// has not changed since LoadPointer.
|
// has not changed since LoadPointer.
|
||||||
data := LoadPointer(&vp.data)
|
data := LoadPointer(&vp.data)
|
||||||
var i any
|
var i any
|
||||||
(*ifaceWords)(unsafe.Pointer(&i)).typ = typ
|
(*efaceWords)(unsafe.Pointer(&i)).typ = typ
|
||||||
(*ifaceWords)(unsafe.Pointer(&i)).data = data
|
(*efaceWords)(unsafe.Pointer(&i)).data = data
|
||||||
if i != old {
|
if i != old {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user