Inheritance: IDisposable
Ejemplo n.º 1
0
        /// <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();
            }
        }
Ejemplo n.º 2
0
        private void popTopTransaction(LiteTransaction trans)
        {
            var temp = _activeTransactions.Peek();

            if (temp != trans)
            {
                throw new ArgumentException("Invalid transaction on top of stack");
            }

            _activeTransactions.Pop();
        }
Ejemplo n.º 3
0
        /// <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);
            }
        }