Commit 2de18e8e authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent c13bd307
...@@ -110,21 +110,17 @@ func NewRef(obj interface{}) *Ref { ...@@ -110,21 +110,17 @@ func NewRef(obj interface{}) *Ref {
// If original object is still alive - it is returned. // If original object is still alive - it is returned.
// If not - nil is returned. // If not - nil is returned.
func (w *Ref) Get() (obj interface{}) { func (w *Ref) Get() (obj interface{}) {
get := false
w.mu.Lock() w.mu.Lock()
if w.state != objReleased { if w.state != objReleased {
w.state = objGot w.state = objGot
get = true
}
w.mu.Unlock()
if get {
time.Sleep(100*time.Nanosecond) time.Sleep(100*time.Nanosecond)
// recreate interface{} from saved words. // recreate interface{} from saved words.
// XXX do writes as pointers so that compiler emits write barriers to notify GC? // XXX do writes as pointers so that compiler emits write barriers to notify GC?
i := (*iface)(unsafe.Pointer(&obj)) i := (*iface)(unsafe.Pointer(&obj))
*i = w.iface *i = w.iface
} }
w.mu.Unlock()
return obj return obj
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment