public unsafe StorageEnvironment(StorageEnvironmentOptions options) { try { TemporaryPage = new TemporaryPage(); _options = options; _dataPager = options.DataPager; _freeSpaceHandling = new FreeSpaceHandling(this); _sliceComparer = NativeMethods.memcmp; _headerAccessor = new HeaderAccessor(this); var isNew = _headerAccessor.Initialize(); _scratchBufferPool = new ScratchBufferPool(this); _journal = new WriteAheadJournal(this); if (isNew) CreateNewDatabase(); else // existing db, let us load it LoadExistingDatabase(); State.FreeSpaceRoot.Name = Constants.FreeSpaceTreeName; State.Root.Name = Constants.RootTreeName; Writer = new TransactionMergingWriter(this, _cancellationTokenSource.Token); if (_options.ManualFlushing == false) _flushingTask = FlushWritesToDataFileAsync(); } catch (Exception) { Dispose(); throw; } }
public ReturnTemporaryPageToPool(StorageEnvironment env, TemporaryPage tmp) { _tmp = tmp; _env = env; }
internal IDisposable GetTemporaryPage(Transaction tx, out TemporaryPage tmp) { if (tx.Flags != TransactionFlags.ReadWrite) throw new ArgumentException("Temporary pages are only available for write transactions"); if (_tempPagesPool.Count > 0) { tmp = _tempPagesPool.Dequeue(); return tmp.ReturnTemporaryPageToPool; } tmp = new TemporaryPage(); try { return tmp.ReturnTemporaryPageToPool = new ReturnTemporaryPageToPool(this, tmp); } catch (Exception) { tmp.Dispose(); throw; } }