Documentation ¶
Overview ¶
Package refsvfs2 defines an interface for a reference-counted object.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DoLeakCheck ¶
func DoLeakCheck()
DoLeakCheck iterates through the live object map and logs a message for each object. It is called once no reference-counted objects should be reachable anymore, at which point anything left in the map is considered a leak.
func LogDecRef ¶
func LogDecRef(obj CheckedObject, refs int64)
LogDecRef logs a reference decrement.
func LogIncRef ¶
func LogIncRef(obj CheckedObject, refs int64)
LogIncRef logs a reference increment.
func LogTryIncRef ¶
func LogTryIncRef(obj CheckedObject, refs int64)
LogTryIncRef logs a successful TryIncRef call.
func Unregister ¶
func Unregister(obj CheckedObject)
Unregister removes obj from the live object map.
Types ¶
type CheckedObject ¶
type CheckedObject interface { // RefType is the type of the reference-counted object. RefType() string // LeakMessage supplies a warning to be printed upon leak detection. LeakMessage() string // LogRefs indicates whether reference-related events should be logged. LogRefs() bool }
CheckedObject represents a reference-counted object with an informative leak detection message.
type RefCounter ¶
type RefCounter interface { // IncRef increments the reference counter on the object. IncRef() // DecRef decrements the object's reference count. Users of refs_template.Refs // may specify a destructor to be called once the reference count reaches zero. DecRef(ctx context.Context) // TryIncRef attempts to increment the reference count, but may fail if all // references have already been dropped, in which case it returns false. If // true is returned, then a valid reference is now held on the object. TryIncRef() bool }
RefCounter is the interface to be implemented by objects that are reference counted.
Click to show internal directories.
Click to hide internal directories.