Skip to content

Commit

Permalink
lang: funcs, interfaces: Add the Graph method
Browse files Browse the repository at this point in the history
The Txn wants to be able to call graph directly.
  • Loading branch information
purpleidea committed Jan 25, 2024
1 parent 67c72a0 commit 7777107
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lang/funcs/txn/txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,3 +624,12 @@ func (obj *GraphTxn) Free() {
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
}
4 changes: 4 additions & 0 deletions lang/interfaces/func.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,4 +339,8 @@ type Txn interface {
// separate state. This allows you to do an Add*/Commit/Reverse that
// isn't affected by a different user of this transaction.
Copy() Txn

// Graph returns a copy of the graph. It returns what has been already
// committed.
Graph() *pgraph.Graph
}

0 comments on commit 7777107

Please sign in to comment.