lang: funcs, interfaces: Add the Graph method

The Txn wants to be able to call graph directly.
This commit is contained in:
James Shubin
2024-01-24 20:45:07 -05:00
parent 67c72a0e86
commit 7777107d83
2 changed files with 13 additions and 0 deletions

View File

@@ -624,3 +624,12 @@ func (obj *GraphTxn) Free() {
obj.FreeFunc() obj.FreeFunc()
} }
} }
// Graph returns a copy of the contained graph. It returns what has been already
// committed.
func (obj *GraphTxn) Graph() *pgraph.Graph {
obj.mutex.Lock()
defer obj.mutex.Unlock()
return obj.GraphAPI.Graph() // returns a copy
}

View File

@@ -339,4 +339,8 @@ type Txn interface {
// separate state. This allows you to do an Add*/Commit/Reverse that // separate state. This allows you to do an Add*/Commit/Reverse that
// isn't affected by a different user of this transaction. // isn't affected by a different user of this transaction.
Copy() Txn Copy() Txn
// Graph returns a copy of the graph. It returns what has been already
// committed.
Graph() *pgraph.Graph
} }