Commit c813d2f8 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 228b439b
......@@ -97,12 +97,14 @@ func NewRef(obj interface{}) *Ref {
// race with any Get in progress, and reschedule us to retry at
// next GC if we do.
w.mu.Lock()
old := w.state
if w.state == objGot {
w.state = objLive
runtime.SetFinalizer(obj, release)
} else {
w.state = objReleased
}
fmt.Printf("rel %p (state: %v -> %v)\n", w, old, w.state)
traceRelease(w)
w.mu.Unlock()
......@@ -121,6 +123,7 @@ func NewRef(obj interface{}) *Ref {
func (w *Ref) Get() (obj interface{}) {
w.mu.Lock()
if w.state != objReleased {
fmt.Printf("got %p (state: %v -> %v)\n", w, w.state, objGot)
w.state = objGot
traceGotPre(w)
......
......@@ -115,7 +115,7 @@ func testWeakRef(t *testing.T) {
case state = <-wrelease:
// ok
case <-time.After(1 * time.Second):
t.Fatalf("no release event (w.state=%v)", w.state)
t.Fatalf("no release event (w.state=%v stateOK=%v)", w.state, stateOK)
}
if state != stateOK {
......
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