refcount

package
v0.0.0-...-a00ca78 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2024 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateFunc

type CreateFunc func() (s interface{}, cleanup ReleaseFunc, err error)

CreateFunc is the function that creates the actual struct

type ReferenceCountable

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

ReferenceCountable is a wrapper that handles the reference counting of an instance

func (*ReferenceCountable) Get

func (r *ReferenceCountable) Get(create CreateFunc) (sr interface{}, rf ReleaseFunc, err error)

Get receives a factory function and returns the instance if exists or creates a new one. In addition it returns ReleaseFunc to be used when the owner no longer needs the instance.

func (*ReferenceCountable) Release

func (r *ReferenceCountable) Release() error

Release should be called when the owner of the instance no longer uses it and would like to release resources.

type ReleaseFunc

type ReleaseFunc func() error

ReleaseFunc should be called by the client when he stopps to use the service

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL