gate

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2025 License: Apache-2.0 Imports: 2 Imported by: 86

Documentation

Overview

Package gate contains a gated function callback registration implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Gate

type Gate[T comparable] struct {
	// contains filtered or unexported fields
}

Gate implements a gated function callback registration with comparable conditions.

func (*Gate[T]) Register

func (g *Gate[T]) Register(fn func(), depends ...T)

Register a callback function that will be called when all the provided dependent conditions are true. After all conditions are true, the callback function is removed from the registration and will not be called again. Thread Safe.

func (*Gate[T]) Set

func (g *Gate[T]) Set(condition T, value bool) bool

Set marks the associated condition to the given value. If the condition is already set as that value, then this is a no-op. Returns true if there was an update detected. Thread safe.

Jump to

Keyboard shortcuts

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