/// <summary> /// Complete transaction commit dirty pages and closing data file /// </summary> public void Complete(LiteTransaction trans) { lock (_activeTransactions) { popTopTransaction(trans); // check if trans are last transaction in stack if (_activeTransactions.Count > 0) { return; } if (_cache.HasDirtyPages) { // save dirty pages this.Save(); // delete journal file - datafile is consist here _disk.DeleteJournal(); } // clear all pages in cache _cache.Clear(); // close datafile _disk.Close(); } }
private void popTopTransaction(LiteTransaction trans) { var temp = _activeTransactions.Peek(); if (temp != trans) { throw new ArgumentException("Invalid transaction on top of stack"); } _activeTransactions.Pop(); }
/// <summary> /// Starts a new transaction - lock database to garantee that only one processes is in a transaction /// </summary> public LiteTransaction Begin(bool readOnly) { lock (_activeTransactions) { _disk.Open(readOnly); var trans = new LiteTransaction(this); _activeTransactions.Push(trans); return(trans); } }