store

package
v4.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: LGPL-3.0 Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package store provides registries keyed by native handle for the callback registrations of taskers, controllers, and resources.

Index

Constants

This section is empty.

Variables

View Source
var (
	TaskerStore = New[TaskerStoreValue]()
	CtrlStore   = New[CtrlStoreValue]()
	ResStore    = New[ResStoreValue]()
)

TaskerStore, CtrlStore, and ResStore track the callback registrations of the package's taskers, controllers, and resources.

Functions

This section is empty.

Types

type CtrlStoreValue

type CtrlStoreValue struct {
	SinkIDToEventCallbackID     map[int64]uint64
	CustomControllerCallbacksID uint64
}

CtrlStoreValue records the callback registrations for one controller: the event callbacks backing its sinks, keyed by sink ID, and the shared custom-controller callback registration.

type ResStoreValue

type ResStoreValue struct {
	SinkIDToEventCallbackID     map[int64]uint64
	CustomRecognizersCallbackID map[string]uint64
	CustomActionsCallbackID     map[string]uint64
}

ResStoreValue records the callback registrations for one resource: the event callbacks backing its sinks, keyed by sink ID, and the custom recognizer and custom action callback registrations, keyed by name.

type Store

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

Store is a registry of values keyed by native handle.

Set, Get, and Del take no lock: the caller must hold Lock for the duration of any sequence of those calls. Update acquires the lock itself and must not be called while the caller holds Lock.

func New

func New[T any]() *Store[T]

New returns an empty Store ready for use.

func (*Store[T]) Del

func (s *Store[T]) Del(handle uintptr)

Del removes the value stored under handle. Deleting an absent handle is a no-op. The caller must hold Lock.

func (*Store[T]) Get

func (s *Store[T]) Get(handle uintptr) T

Get returns the value stored under handle, or the zero value of T when handle is absent. The caller must hold Lock.

func (*Store[T]) Lock

func (s *Store[T]) Lock()

Lock locks the store exclusively, guarding the Set, Get, and Del calls made while it is held.

func (*Store[T]) Set

func (s *Store[T]) Set(handle uintptr, value T)

Set stores value under handle, replacing any previous value. The caller must hold Lock.

func (*Store[T]) Unlock

func (s *Store[T]) Unlock()

Unlock releases the store. Every Lock call must be paired with exactly one Unlock.

func (*Store[T]) Update

func (s *Store[T]) Update(handle uintptr, fn func(*T))

Update locks the store, passes a pointer to a copy of the value stored under handle — the zero value of T when absent — to fn, stores the modified copy, and unlocks. Unlike Set, Get, and Del, Update must be called without holding Lock.

type TaskerStoreValue

type TaskerStoreValue struct {
	SinkIDToEventCallbackID        map[int64]uint64
	ContextSinkIDToEventCallbackID map[int64]uint64
}

TaskerStoreValue records the callback registrations for one tasker: the event callbacks backing its sinks and the event callbacks backing its context-scoped sinks, each keyed by sink ID.

Jump to

Keyboard shortcuts

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