예제 #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();
            }
        }
        /// <summary>
        ///     Commit the transaction - increese
        /// </summary>
        public void Commit()
        {
            if (_trans == false)
            {
                throw new Exception("No begin transaction");
            }

            if (_cache.HasDirtyPages)
            {
                // save dirty pages
                Save();

                // clear all pages in cache
                _cache.Clear();
            }

            // delete journal file - datafile is consist here
            _disk.DeleteJournal();

            // unlock datafile
            _disk.Unlock();

            _trans = false;
        }