refctr

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Counter

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

func (*Counter) Dec

func (r *Counter) Dec(release func())

Dec decrements the counter and calls the release function, if this is the last reference.

func (*Counter) Inc

func (r *Counter) Inc(init func() error) (err error)

Inc increments the counter and calls the init function, if this is the first reference. The call returns an error only if init call has failed, and the reference has not been incremented.

func (*Counter) IncErr added in v1.8.0

func (r *Counter) IncErr(init func() error) (err error)

IncErr is identical to Inc, with the only difference that if the function fails, the error is returned on any further IncErr call, preventing from calling the faulty initialization function again.

Jump to

Keyboard shortcuts

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