func (v *Value) Load() (val interface{}) {
vp := (*ifaceWords)(unsafe.Pointer(v))
typ := LoadPointer(&vp.typ)
- if typ == nil || uintptr(typ) == ^uintptr(0) {
+ if typ == nil || typ == unsafe.Pointer(&firstStoreInProgress) {
// First store not yet completed.
return nil
}
return
}
+var firstStoreInProgress byte
+
// Store sets the value of the Value to x.
// All calls to Store for a given Value must use values of the same concrete type.
// Store of an inconsistent type panics, as does Store(nil).
if typ == nil {
// Attempt to start first store.
// Disable preemption so that other goroutines can use
- // active spin wait to wait for completion; and so that
- // GC does not see the fake type accidentally.
+ // active spin wait to wait for completion.
runtime_procPin()
- if !CompareAndSwapPointer(&vp.typ, nil, unsafe.Pointer(^uintptr(0))) {
+ if !CompareAndSwapPointer(&vp.typ, nil, unsafe.Pointer(&firstStoreInProgress)) {
runtime_procUnpin()
continue
}
runtime_procUnpin()
return
}
- if uintptr(typ) == ^uintptr(0) {
+ if typ == unsafe.Pointer(&firstStoreInProgress) {
// First store in progress. Wait.
// Since we disable preemption around the first store,
// we can wait with active spinning.