reference

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: Apache-2.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 Counter

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

Counter counts the references to a resource. When the counter is closed then the provided close func is invoked only after the count reaches 0.

func NewCounter

func NewCounter(closer func()) *Counter

NewCounter returns a new Counter. The provided function is invoked when the counter is closed and the reference count is 0.

func (*Counter) Close

func (r *Counter) Close()

Close closes the counter, which will cause the close function to be invoked after the count reaches 0.

func (*Counter) Decrement

func (r *Counter) Decrement() (int32, error)

Decrement decrements the count by 1. If the counter has already been closed AND the count reaches 0 then the close function is invoked. An error is returned if the function is invoked when the count is 0.

func (*Counter) Increment

func (r *Counter) Increment() (int32, error)

Increment increments the count by 1. An error is returned if the function is invoked on a closed counter.

Jump to

Keyboard shortcuts

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