func (e *entryVT) tryLoadOrStore(i VT) (actual VT, loaded, ok bool) {
	p := atomic.LoadPointer(&e.p)
	if p == expungedVT {
		return nil, false, false
	}
	if p != nil {
		return *(*VT)(p), true, true
	}
	ic := i
	for {
		if atomic.CompareAndSwapPointer(&e.p, nil, unsafe.Pointer(&ic)) {
			return i, false, true
		}
		p = atomic.LoadPointer(&e.p)
		if p == expungedVT {
			return nil, false, false
		}
		if p != nil {
			return *(*VT)(p), true, true
		}
	}
}
tryLoadOrStore atomically loads or stores a value if the entryVT is not
expungedVT.

If the entryVT is expungedVT, tryLoadOrStore leaves the entryVT unchanged and
returns with ok==false.
package atomicMap
import (
	"sync"
	"sync/atomic"
	"unsafe"
)
type (
	KT interface{}
	VT interface{}
)
type MapKTVT struct {
	mu sync.Mutex
	read atomic.Value  
	dirty map[KT]*entryVT
	misses int
}
type readOnlyKTVT struct {
	m       map[KT]*entryVT
	amended bool  
}
var expungedVT = unsafe.Pointer(new(VT))
type entryVT struct {
	p unsafe.Pointer  
}
func newEntryVT(i VT) *entryVT {
	return &entryVT{p: unsafe.Pointer(&i)}
}
func (m *MapKTVT) Load(key KT) (value VT, ok bool) {
	read, _ := m.read.Load().(readOnlyKTVT)
	e, ok := read.m[key]
	if !ok && read.amended {
		m.mu.Lock()
		read, _ = m.read.Load().(readOnlyKTVT)
		e, ok = read.m[key]
		if !ok && read.amended {
			e, ok = m.dirty[key]
			m.missLocked()
		}
		m.mu.Unlock()
	}
	if !ok {
		return nil, false
	}
	return e.load()
}
func (e *entryVT) load() (value VT, ok bool) {
	p := atomic.LoadPointer(&e.p)
	if p == nil || p == expungedVT {
		return nil, false
	}
	return *(*VT)(p), true
}
func (m *MapKTVT) Store(key KT, value VT) {
	read, _ := m.read.Load().(readOnlyKTVT)
	if e, ok := read.m[key]; ok && e.tryStore(&value) {
		return
	}
	m.mu.Lock()
	read, _ = m.read.Load().(readOnlyKTVT)
	if e, ok := read.m[key]; ok {
		if e.unexpungeLocked() {
			m.dirty[key] = e
		}
		e.storeLocked(&value)
	} else if e, ok := m.dirty[key]; ok {
		e.storeLocked(&value)
	} else {
		if !read.amended {
			m.dirtyLocked()
			m.read.Store(readOnlyKTVT{m: read.m, amended: true})
		}
		m.dirty[key] = newEntryVT(value)
	}
	m.mu.Unlock()
}
func (e *entryVT) tryStore(i *VT) bool {
	p := atomic.LoadPointer(&e.p)
	if p == expungedVT {
		return false
	}
	for {
		if atomic.CompareAndSwapPointer(&e.p, p, unsafe.Pointer(i)) {
			return true
		}
		p = atomic.LoadPointer(&e.p)
		if p == expungedVT {
			return false
		}
	}
}
func (e *entryVT) unexpungeLocked() (wasExpungedVT bool) {
	return atomic.CompareAndSwapPointer(&e.p, expungedVT, nil)
}
func (e *entryVT) storeLocked(i *VT) {
	atomic.StorePointer(&e.p, unsafe.Pointer(i))
}
func (m *MapKTVT) LoadOrStore(key KT, value VT) (actual VT, loaded bool) {
	read, _ := m.read.Load().(readOnlyKTVT)
	if e, ok := read.m[key]; ok {
		actual, loaded, ok = e.tryLoadOrStore(value)
		if ok {
			return actual, loaded
		}
	}
	m.mu.Lock()
	read, _ = m.read.Load().(readOnlyKTVT)
	if e, ok := read.m[key]; ok {
		if e.unexpungeLocked() {
			m.dirty[key] = e
		}
		actual, loaded, _ = e.tryLoadOrStore(value)
	} else if e, ok := m.dirty[key]; ok {
		actual, loaded, _ = e.tryLoadOrStore(value)
		m.missLocked()
	} else {
		if !read.amended {
			m.dirtyLocked()
			m.read.Store(readOnlyKTVT{m: read.m, amended: true})
		}
		m.dirty[key] = newEntryVT(value)
		actual, loaded = value, false
	}
	m.mu.Unlock()
	return actual, loaded
}