callstack

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallStack

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

func NewCallStack

func NewCallStack() *CallStack

NewCallStack creates a new CallStack

func (*CallStack) Add

func (c *CallStack) Add(fn CallableFn)

Add Adds a callback

func (*CallStack) IsCalling

func (c *CallStack) IsCalling() bool

IsCalling returns true if in call loop

func (*CallStack) Run

func (c *CallStack) Run(abortOnError bool) error

Run executes the callback functions in the CallStack in reverse order. If abortOnError is true and any of the callback functions return an error, the execution stops and returns that error. If abortOnError is false, all callback functions are executed, regardless of errors, and the errors returned by the callbacks are combined with errors.Join. The callbacks registered at the time of the call are executed without holding the CallStack lock, so a callback may safely call Add; callbacks added during execution are not executed by the current call. The calling flag is set to 1 during the execution and reset to 0 after execution. If the CallStack is empty, Run returns nil.

func (*CallStack) RunLinear

func (c *CallStack) RunLinear(abortOnError bool) error

RunLinear executes each callback function in the call stack linearly. Error handling and locking behave as in Run.

type CallableFn

type CallableFn func() error

CallableFn CallStack callable function

Jump to

Keyboard shortcuts

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