resourcemanager

package
v1.12.6 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ResourceManager

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

ResourceManager is a fair manager for distributing limited amount of resources to requesters.

func New

func New[T any](limit int64) *ResourceManager[T]

New returns a new ResourceManager with `limit` number of resources.

func (*ResourceManager[T]) Close

func (m *ResourceManager[T]) Close()

Close resource manager.

func (*ResourceManager[T]) Release

func (m *ResourceManager[T]) Release(n int64)

Release `n` resource to the manager.

func (*ResourceManager[T]) Request

func (m *ResourceManager[T]) Request(key string, data T, n int64, notifyC chan T, cancelC chan struct{}) (acquired bool)

Request `n` resource from the manager for key `key`. Release must be called after done with the resource.

func (*ResourceManager[T]) Stats

func (m *ResourceManager[T]) Stats() Stats

Stats returns statistics about current status.

type Stats

type Stats struct {
	AllocatedSize    int64
	AllocatedObjects int
	PendingKeys      int
}

Stats about ResourceManager

Jump to

Keyboard shortcuts

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