Skip to content

Commit 3ab0c7e

Browse files
committed
fix(model-api): deprecation of ModelFacade.toLocalBranch
Also added new alternatives functions `newBranch` and `newUnsafeBranch`.
1 parent f6e99fa commit 3ab0c7e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

model-client/src/commonMain/kotlin/org/modelix/model/ModelFacade.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,20 @@ object ModelFacade {
5555
return loadCurrentVersion(client, branch)?.getTree()
5656
}
5757

58+
/**
59+
* The default thread-safe implementation of IBranch that enforces transactions.
60+
*/
61+
fun newBranch(tree: ITree): IBranch = PBranch(tree, IdGenerator.getInstance(1))
62+
63+
/**
64+
* A performance optimized branch that isn't thread-safe and doesn't enforce transactions.
65+
* Should only be used for short living instances that are guaranteed to be used by a single thread.
66+
* Not suitable for unit tests, because of the lack of enforcing transactions.
67+
* Unless performance isn't critical .newBranch should be used instead.
68+
*/
69+
fun newUnsafeBranch(tree: ITree): IBranch = TreePointer(tree, IdGenerator.getInstance(1))
70+
71+
@Deprecated("Use .toUnsafeBranch or .newBranch")
5872
fun toLocalBranch(tree: ITree): IBranch = TreePointer(tree, IdGenerator.getInstance(1))
5973

6074
fun toNode(tree: ITree): INode {

0 commit comments

Comments
 (0)