lang: funcs: ref: Move reference counting code to a new package

This also makes it public, although it is designed for internal use
only.
This commit is contained in:
James Shubin
2024-01-22 14:12:46 -05:00
parent 66b826a8e1
commit 28eacdb2bb
4 changed files with 32 additions and 30 deletions

View File

@@ -30,6 +30,7 @@ import (
"github.com/purpleidea/mgmt/engine"
"github.com/purpleidea/mgmt/engine/local"
"github.com/purpleidea/mgmt/lang/funcs/ref"
"github.com/purpleidea/mgmt/lang/funcs/structs"
"github.com/purpleidea/mgmt/lang/interfaces"
"github.com/purpleidea/mgmt/lang/types"
@@ -71,7 +72,7 @@ type Engine struct {
// refCount keeps track of vertex and edge references across the entire
// graph.
refCount *RefCount
refCount *ref.Count
// wgTxn blocks shutdown until the initial Txn has Reversed.
wgTxn *sync.WaitGroup
@@ -161,7 +162,7 @@ func (obj *Engine) Setup() error {
obj.graphMutex = &sync.Mutex{} // TODO: &sync.RWMutex{} ?
obj.tableMutex = &sync.RWMutex{}
obj.refCount = (&RefCount{}).Init()
obj.refCount = (&ref.Count{}).Init()
obj.wgTxn = &sync.WaitGroup{}