github.com/go-eden/common@v0.1.15-0.20210617133546-059099253264/esync/sync_atomic_pointer.go (about) 1 package esync 2 3 import ( 4 "sync/atomic" 5 ) 6 7 type AtomicPointer struct { 8 p atomic.Value 9 } 10 11 func (t *AtomicPointer) Get() interface{} { 12 if v := t.p.Load(); v != nil { 13 return *(v.(*interface{})) 14 } 15 return nil 16 } 17 18 func (t *AtomicPointer) Set(v interface{}) { 19 t.p.Store(&v) 20 }