本文整理汇总了C#中Voron.Impl.Transaction.EnsurePagerStateReference方法的典型用法代码示例。如果您正苦于以下问题:C# Transaction.EnsurePagerStateReference方法的具体用法?C# Transaction.EnsurePagerStateReference怎么用?C# Transaction.EnsurePagerStateReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Voron.Impl.Transaction
的用法示例。
在下文中一共展示了Transaction.EnsurePagerStateReference方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AllocateMorePages
public override void AllocateMorePages(Transaction tx, long newLength)
{
ThrowObjectDisposedIfNeeded();
var newLengthAfterAdjustment = NearestSizeToAllocationGranularity(newLength);
if (newLengthAfterAdjustment <= _totalAllocationSize)
return;
var allocationSize = newLengthAfterAdjustment - _totalAllocationSize;
if (TryAllocateMoreContinuousPages(allocationSize) == false)
{
var newPagerState = AllocateMorePagesAndRemapContinuously(allocationSize);
if (newPagerState == null)
{
var errorMessage = string.Format(
"Unable to allocate more pages - unsuccessfully tried to allocate continuous block of virtual memory with size = {0:##,###;;0} bytes",
(_totalAllocationSize + allocationSize));
throw new OutOfMemoryException(errorMessage);
}
newPagerState.DebugVerify(newLengthAfterAdjustment);
newPagerState.AddRef();
if (tx != null)
{
tx.EnsurePagerStateReference(newPagerState);
}
// we always share the same memory mapped files references between all pages, since to close them
// would be to lose all the memory associated with them
PagerState.DisposeFilesOnDispose = false;
var tmp = PagerState;
PagerState = newPagerState;
tmp.Release(); //replacing the pager state --> so one less reference for it
}
_totalAllocationSize += allocationSize;
NumberOfAllocatedPages = _totalAllocationSize / PageSize;
}
示例2: RefreshMappedView
public void RefreshMappedView(Transaction tx)
{
PagerState newPagerState = CreatePagerState();
if (tx != null)
{
tx.EnsurePagerStateReference(newPagerState);
}
var tmp = PagerState;
PagerState = newPagerState;
tmp.Release(); //replacing the pager state --> so one less reference for it
}
示例3: NewTransaction
public Transaction NewTransaction(TransactionFlags flags, TimeSpan? timeout = null)
{
bool txLockTaken = false;
try
{
if (flags == (TransactionFlags.ReadWrite))
{
var wait = timeout ?? (Debugger.IsAttached ? TimeSpan.FromMinutes(30) : TimeSpan.FromSeconds(30));
Monitor.TryEnter(_txWriter, wait, ref txLockTaken);
if (txLockTaken == false)
{
throw new TimeoutException("Waited for " + wait +
" for transaction write lock, but could not get it");
}
if (_endOfDiskSpace != null)
{
if (_endOfDiskSpace.CanContinueWriting)
{
var flushingTask = _flushingTask;
Debug.Assert(flushingTask != null && (flushingTask.Status == TaskStatus.Canceled || flushingTask.Status == TaskStatus.RanToCompletion));
_cancellationTokenSource = new CancellationTokenSource();
_flushingTask = FlushWritesToDataFileAsync();
_endOfDiskSpace = null;
}
}
}
Transaction tx;
_txCommit.EnterReadLock();
try
{
long txId = flags == TransactionFlags.ReadWrite ? _transactionsCounter + 1 : _transactionsCounter;
tx = new Transaction(this, txId, flags, _freeSpaceHandling);
if (IsDebugRecording)
{
RecordTransactionState(tx, DebugActionType.TransactionStart);
tx.RecordTransactionState = RecordTransactionState;
}
}
finally
{
_txCommit.ExitReadLock();
}
_activeTransactions.Add(tx);
tx.EnsurePagerStateReference(_dataPager.PagerState);
if (flags == TransactionFlags.ReadWrite)
{
tx.AfterCommit = TransactionAfterCommit;
}
return tx;
}
catch (Exception)
{
if (txLockTaken)
Monitor.Exit(_txWriter);
throw;
}
}
示例4: AllocateMorePages
public override void AllocateMorePages(Transaction tx, long newLength)
{
ThrowObjectDisposedIfNeeded();
var newLengthAfterAdjustment = NearestSizeToPageSize(newLength);
if (newLengthAfterAdjustment <= _totalAllocationSize)
return;
var allocationSize = newLengthAfterAdjustment - _totalAllocationSize;
PosixHelper.AllocateFileSpace(_fd, (ulong) (_totalAllocationSize + allocationSize));
PagerState newPagerState = CreatePagerState();
if (newPagerState == null)
{
var errorMessage = string.Format(
"Unable to allocate more pages - unsuccessfully tried to allocate continuous block of virtual memory with size = {0:##,###;;0} bytes",
(_totalAllocationSize + allocationSize));
throw new OutOfMemoryException(errorMessage);
}
newPagerState.DebugVerify(newLengthAfterAdjustment);
if (tx != null)
{
tx.EnsurePagerStateReference(newPagerState);
}
var tmp = PagerState;
PagerState = newPagerState;
tmp.Release(); //replacing the pager state --> so one less reference for it
_totalAllocationSize += allocationSize;
NumberOfAllocatedPages = _totalAllocationSize/PageSize;
}