Mercurial > hg > Database > jungle-sharp
comparison src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle-network/transaction/NetworkTransactionManager.cs @ 10:abe0c247f5a5
Add Network module. but, unComplete NetworkDefaultJungleTreeEditor.cs
author | Kazuma Takeda <kazuma-arashi@hotmail.co.jp> |
---|---|
date | Sun, 23 Oct 2016 07:40:50 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
9:e6ad9016601c | 10:abe0c247f5a5 |
---|---|
1 using UnityEngine; | |
2 using System.Collections; | |
3 using System.Collections.Generic; | |
4 | |
5 public class NetworkTransactionManager : TransactionManager { | |
6 | |
7 private readonly AtomicReference<TreeContext> Repository; | |
8 private readonly TreeContext TContext; | |
9 private readonly ChangeListWriter Writer; | |
10 private readonly string Uuid; | |
11 private readonly string TreeName; | |
12 | |
13 public NetworkTransactionManager (string name, ChangeListWriter writer, TreeContext tcon, AtomicReference<TreeContext> repo, string uid) { | |
14 this.Repository = repo; | |
15 this.TContext = tcon; | |
16 this.Writer = writer; | |
17 this.Uuid = uid; | |
18 this.TreeName = name; | |
19 } | |
20 | |
21 public Either<Error, TransactionManager> commit (TreeNode newRoot, TreeOperationLog log) { | |
22 long currentRevision = this.TContext.getRevision(); | |
23 long nextRevision = currentRevision + 1; | |
24 | |
25 ChangeList list = new InnerChangeList(this.Uuid, this.TreeName); | |
26 | |
27 InterfaceTraverser traverser = new InterfaceTraverser(newRoot, true); | |
28 // not create index. | |
29 TreeContext newTreeContext = new DefaultTreeContext(newRoot, this.TContext, list, this.Uuid, this.TreeName, nextRevision, traverser); | |
30 if (this.Repository.CompareAndSet(newTreeContext.prev(), newTreeContext)) { | |
31 TransactionManager txmanager = new NetworkTransactionManager(this.TreeName, this.Writer, newTreeContext, this.Repository, this.Uuid); | |
32 return DefaultEither<Error, TransactionManager>.newB(txmanager); | |
33 } | |
34 | |
35 return DefaultEither<Error, TransactionManager>.newA((Error) new DefaultError()); | |
36 } | |
37 | |
38 public long getRevision () { | |
39 return this.TContext.getRevision(); | |
40 } | |
41 | |
42 public string getUUID () { | |
43 return this.Uuid; | |
44 } | |
45 | |
46 public Either<Error, TransactionManager> firstcommit(TreeNode _newRoot, TreeOperationLog _log) { | |
47 return null; | |
48 } | |
49 | |
50 public class InnerChangeList : ChangeList { | |
51 string uuid; | |
52 string name; | |
53 | |
54 | |
55 IEnumerator IEnumerable.GetEnumerator() | |
56 { | |
57 return this.GetEnumerator(); | |
58 } | |
59 | |
60 public IEnumerator<TreeOperation> GetEnumerator() | |
61 { | |
62 return iterator (); | |
63 } | |
64 | |
65 // construct | |
66 public InnerChangeList(string _uuid, string _name) { | |
67 this.uuid = _uuid; | |
68 this.name = _name; | |
69 } | |
70 | |
71 public IEnumerator<TreeOperation> iterator() { | |
72 List<TreeOperation> nil = new List<TreeOperation>(); | |
73 return nil.iterator(); | |
74 } | |
75 | |
76 public string uuids() { | |
77 return uuid; | |
78 } | |
79 | |
80 public string getTreeName() { | |
81 return name; | |
82 } | |
83 | |
84 public TreeOperationLog getLog() { | |
85 return new DefaultTreeOperationLog(); | |
86 } | |
87 } | |
88 } |