Documentation

Overview

    Package weak provides weak references for Go.

    Index

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    This section is empty.

    Types

    type Ref

    type Ref struct {
    	// contains filtered or unexported fields
    }

      Ref is a weak reference.

      Create one with NewRef and retrieve referenced object with Get.

      There must be no more than 1 weak reference to any object. Weak references must not be attached to an object on which runtime.SetFinalizer is also used. Weak references must not be copied.

      func NewRef

      func NewRef(obj interface{}) *Ref

        NewRef creates new weak reference pointing to obj.

        TODO + onrelease callback?

        func (*Ref) Get

        func (w *Ref) Get() (obj interface{})

          Get returns object pointed to by this weak reference.

          If original object is still alive - it is returned. If not - nil is returned.

          Source Files