19 using System.Collections.Generic;
22 namespace Deveel.Data.Transactions {
29 transactions =
new List<ITransaction>();
30 minCommitId = Int64.MaxValue;
37 return transactions.Count;
44 long currentCommitId = transaction.
CommitId;
45 if (currentCommitId < maxCommitId)
46 throw new InvalidOperationException(
"Added a transaction with a lower than maximum commit id");
48 transactions.Add(transaction);
50 maxCommitId = currentCommitId;
56 int size = transactions.Count;
57 int i = transactions.IndexOf(transaction);
62 minCommitId = Int32.MaxValue;
65 minCommitId = transactions[i + 1].CommitId;
67 }
else if (i == transactions.Count - 1) {
69 maxCommitId = transactions[i - 1].CommitId;
71 throw new InvalidOperationException(
"Unable to find transaction in the list.");
74 transactions.RemoveAt(i);
81 long commitId = Int64.MaxValue;
82 if (transactions.Count > 0) {
86 var testTransaction = transactions[0];
87 if (testTransaction != transaction) {
88 commitId = testTransaction.CommitId;
89 }
else if (transactions.Count > 1) {
90 commitId = transactions[1].CommitId;
100 return transactions.GetEnumerator();
104 IEnumerator IEnumerable.GetEnumerator() {
105 return GetEnumerator();
110 return transactions.FirstOrDefault(x => x.CommitId == commitId);
ITransaction FindById(int commitId)
IEnumerator< ITransaction > GetEnumerator()
int CommitId
Gets a number uniquely identifying a transaction within a database context.
void RemoveTransaction(ITransaction transaction)
readonly List< ITransaction > transactions
void AddTransaction(ITransaction transaction)
The simplest implementation of a transaction.
long MinimumCommitId(ITransaction transaction)