package ref
import "github.com/purpleidea/mgmt/lang/funcs/ref"
Package ref implements reference counting for the graph API and function engine.
Index ¶
- type Count
- func (obj *Count) EdgeDec(f1, f2 interfaces.Func, fe *interfaces.FuncEdge) (bool, bool)
- func (obj *Count) EdgeInc(f1, f2 interfaces.Func, fe *interfaces.FuncEdge) (bool, bool)
- func (obj *Count) FreeEdge(f1, f2 interfaces.Func, arg string) error
- func (obj *Count) FreeVertex(f interfaces.Func) error
- func (obj *Count) GC(graphAPI interfaces.GraphAPI) error
- func (obj *Count) Init() *Count
- func (obj *Count) Lock()
- func (obj *Count) String() string
- func (obj *Count) Unlock()
- func (obj *Count) VertexDec(f interfaces.Func) bool
- func (obj *Count) VertexInc(f interfaces.Func) bool
- type CountEdge
Types ¶
type Count ¶
type Count struct {
// contains filtered or unexported fields
}
Count keeps track of vertex and edge references across the entire graph. Make sure to lock access somehow, ideally with the provided Locker interface.
func (*Count) EdgeDec ¶
func (obj *Count) EdgeDec(f1, f2 interfaces.Func, fe *interfaces.FuncEdge) (bool, bool)
EdgeDec decrements the reference count for the input edge. It removes a reference for each arg name in the edge. Since this also decrements the references for the two input vertices, it returns the corresponding two boolean values for these calls. (This function makes two calls to VertexDec.)
func (*Count) EdgeInc ¶
func (obj *Count) EdgeInc(f1, f2 interfaces.Func, fe *interfaces.FuncEdge) (bool, bool)
EdgeInc increments the reference count for the input edge. It adds a reference for each arg name in the edge. Since this also increments the references for the two input vertices, it returns the corresponding two boolean values for these calls. (This function makes two calls to VertexInc.)
func (*Count) FreeEdge ¶
func (obj *Count) FreeEdge(f1, f2 interfaces.Func, arg string) error
FreeEdge removes exactly one entry from the Edges list or it errors.
func (*Count) FreeVertex ¶
func (obj *Count) FreeVertex(f interfaces.Func) error
FreeVertex removes exactly one entry from the Vertices list or it errors.
func (*Count) GC ¶
func (obj *Count) GC(graphAPI interfaces.GraphAPI) error
GC runs the garbage collector on any zeroed references. Note the distinction between count == 0 (please delete now) and absent from the map.
func (*Count) Init ¶
Init must be called to initialized the struct before first use.
func (*Count) Lock ¶
func (obj *Count) Lock()
Lock the mutex that should be used when reading or writing from this.
func (*Count) String ¶
String prints a representation of the references held.
func (*Count) Unlock ¶
func (obj *Count) Unlock()
Unlock the mutex that should be used when reading or writing from this.
func (*Count) VertexDec ¶
func (obj *Count) VertexDec(f interfaces.Func) bool
VertexDec decrements the reference count for the input vertex. It returns true if the reference count for this vertex is now zero. True usually means we'd want to actually remove this vertex now. If you attempt to decrement a vertex which already has a zero count, then this will panic.
func (*Count) VertexInc ¶
func (obj *Count) VertexInc(f interfaces.Func) bool
VertexInc increments the reference count for the input vertex. It returns true if the reference count for this vertex was previously undefined or zero. True usually means we'd want to actually add this vertex now. If you attempt to increment a vertex which already has a less than zero count, then this will panic. This situation is likely impossible unless someone modified the reference counting struct directly.
type CountEdge ¶
type CountEdge struct {
// contains filtered or unexported fields
}
CountEdge is a virtual "hash" entry for the Count edges map key.
Source Files ¶
- Version
- v0.0.0-20250322185616-c50a578426f1 (latest)
- Published
- Mar 22, 2025
- Platform
- linux/amd64
- Imports
- 4 packages
- Last checked
- 4 days ago –
Tools for package owners.