pool

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InvokeIDPool

type InvokeIDPool struct {
	sync.Mutex
	// contains filtered or unexported fields
}

InvokeIDPool is used to ensure that the set of IDs in use concurrently never contains any duplicates. The IDs start at 1 and increase without bound, but will never be larger than the peak number of concurrent uses.

InvokeIDPool's Get() and Release() methods can be used concurrently.

func NewInvokeIDPool

func NewInvokeIDPool() *InvokeIDPool

NewInvokeIDPool creates and initializes an IDPool.

func (*InvokeIDPool) Get

func (pool *InvokeIDPool) Get() (id uint32)

Get returns an ID that is unique among currently active users of this pool.

func (*InvokeIDPool) Release

func (pool *InvokeIDPool) Release(id uint32)

Release recycles an ID back into the pool for others to use. Releasing back a value or 0, or a value that is not currently "checked out", will result in a panic because that should never happen except in the case of a programming error.

Jump to

Keyboard shortcuts

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