callstack

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2025 License: Apache-2.0 Imports: 2 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. The CallStack is locked while executing the callbacks to ensure thread safety. The calling flag is set to 1 during the execution and reset to 0 after execution. If the CallStack is empty, Run returns nil. Returns an error if abortOnError is true and any callback function returns an error; otherwise, returns nil.

func (*CallStack) RunLinear

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

RunLinear executes each callback function in the call stack linearly.

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