refcount

package
v0.2.24-cluster Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2018 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 Closer

type Closer func()

Closer closes the resource

type ReferenceCounter

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

ReferenceCounter is a reference counter which allows you to safely close a resource when it's no longer in use.

func New

func New(closer Closer) *ReferenceCounter

New returns a new reference counter

func (*ReferenceCounter) Acquire

func (c *ReferenceCounter) Acquire() bool

Acquire adds a reference

func (*ReferenceCounter) Close

func (c *ReferenceCounter) Close() bool

Close closes the resource when the last reference is released

func (*ReferenceCounter) Release

func (c *ReferenceCounter) Release() bool

Release releases a reference

Jump to

Keyboard shortcuts

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