arc

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Arc is an atomically reference counted generic type.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Arc

type Arc[T any] struct {
	// contains filtered or unexported fields
}

Arc is an atomically reference counted generic type. It is specifically designed to be used in a pool.

func NewArc

func NewArc[T any](v T) *Arc[T]

New creates a new Arc[T] with the given value.

func (*Arc[T]) Dec

func (a *Arc[T]) Dec() int32

Dec decrements the reference count of the Arc[T].

func (*Arc[T]) Inc

func (a *Arc[T]) Inc()

Inc increments the reference count of the Arc[T].

func (*Arc[T]) Load

func (a *Arc[T]) Load() T

Load returns the value of the Arc[T].

type ArcPool

type ArcPool[T any] struct {
	sync_pool.SyncPool[*Arc[T]]
}

ArcPool is a sync pool based on reference counting. When the counter reaches zero, the value is returned to the pool.

func NewArcPool

func NewArcPool[T any](init func() T, reset func(T)) *ArcPool[T]

NewArcPool creates a new ArcPool[T].

Jump to

Keyboard shortcuts

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