当前位置: 首页>>代码示例>>C#>>正文


C# Transaction.AddPagerState方法代码示例

本文整理汇总了C#中Voron.Impl.Transaction.AddPagerState方法的典型用法代码示例。如果您正苦于以下问题:C# Transaction.AddPagerState方法的具体用法?C# Transaction.AddPagerState怎么用?C# Transaction.AddPagerState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Voron.Impl.Transaction的用法示例。


在下文中一共展示了Transaction.AddPagerState方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AllocateMorePages

		public override void AllocateMorePages(Transaction tx, long newLength)
		{
			if (newLength < _fileStream.Length)
				throw new ArgumentException("Cannot set the legnth to less than the current length");

			if (newLength == _fileStream.Length)
				return;

			// need to allocate memory again
			_fileStream.SetLength(newLength);
			PagerState.Release(); // when the last transaction using this is over, will dispose it
			PagerState newPager = CreateNewPagerState();

			if (tx != null) // we only pass null during startup, and we don't need it there
			{
				newPager.AddRef(); // one for the current transaction
				tx.AddPagerState(newPager);
			}

			PagerState = newPager;
			NumberOfAllocatedPages = newPager.Accessor.Capacity / PageSize;
		}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:22,代码来源:MemoryMapPager.cs

示例2: AllocateMorePages

		public override void AllocateMorePages(Transaction tx, long newLength)
		{
			ThrowObjectDisposedIfNeeded();

			var newLengthAfterAdjustment = NearestSizeToAllocationGranularity(newLength);

			if (newLengthAfterAdjustment < _totalAllocationSize)
				throw new ArgumentException("Cannot set the length to less than the current length");

			if (newLengthAfterAdjustment == _totalAllocationSize)
				return;

			var allocationSize = newLengthAfterAdjustment - _totalAllocationSize;

			Win32NativeFileMethods.SetFileLength(_handle, _totalAllocationSize + allocationSize);
			if (TryAllocateMoreContinuousPages(allocationSize) == false)
			{
				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)
				{
					newPagerState.AddRef();
					tx.AddPagerState(newPagerState);
				}

				var tmp = PagerState;
				PagerState = newPagerState;
				tmp.Release(); //replacing the pager state --> so one less reference for it
			}

			_totalAllocationSize += allocationSize;
			NumberOfAllocatedPages = _totalAllocationSize / PageSize;
		}
开发者ID:bbqchickenrobot,项目名称:ravendb,代码行数:43,代码来源:Win32MemoryMapPager.cs

示例3: AllocateMorePages

        public override void AllocateMorePages(Transaction tx, long newLength)
        {
            ThrowObjectDisposedIfNeeded();

            var newLengthAfterAdjustment = NearestSizeToPageSize(newLength);

            if (newLengthAfterAdjustment <= _totalAllocationSize) //nothing to do
                return;

            var allocationSize = newLengthAfterAdjustment - _totalAllocationSize;

            PosixHelper.AllocateFileSpace(_fd, (ulong)(_totalAllocationSize + allocationSize));
            _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)
            {
                newPagerState.AddRef();
                tx.AddPagerState(newPagerState);
            }

            var tmp = PagerState;
            PagerState = newPagerState;
            tmp.Release(); //replacing the pager state --> so one less reference for it

            NumberOfAllocatedPages = _totalAllocationSize / PageSize;
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:38,代码来源:PosixTempMemoryMapPager.cs

示例4: 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);
		        var state = _dataPager.TransactionBegan();
		        tx.AddPagerState(state);

		        if (flags == TransactionFlags.ReadWrite)
		        {
			        tx.AfterCommit = TransactionAfterCommit;
		        }

		        return tx;
	        }
            catch (Exception)
            {
                if (txLockTaken)
					Monitor.Exit(_txWriter);
                throw;
            }
        }
开发者ID:VPashkov,项目名称:ravendb,代码行数:65,代码来源:StorageEnvironment.cs

示例5: AllocateMorePages

		public override void AllocateMorePages(Transaction tx, long newLength)
		{
			ThrowObjectDisposedIfNeeded();
			var newLengthAfterAdjustment = NearestSizeToAllocationGranularity(newLength);

			if (newLengthAfterAdjustment < _totalAllocationSize)
				throw new ArgumentException("Cannot set the length to less than the current length");

			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)
		        {
		            newPagerState.AddRef();
		            tx.AddPagerState(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;
		}
开发者ID:cocytus,项目名称:ravendb,代码行数:43,代码来源:Win32PageFileBackedMemoryMappedPager.cs

示例6: RefreshMappedView

        public void RefreshMappedView(Transaction tx)
        {
            PagerState newPagerState = CreatePagerState();

            if (tx != null)
            {
                newPagerState.AddRef();
                tx.AddPagerState(newPagerState);
            }

            var tmp = PagerState;
            PagerState = newPagerState;
            tmp.Release(); //replacing the pager state --> so one less reference for it
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:14,代码来源:Win32MemoryMapPager.cs


注:本文中的Voron.Impl.Transaction.AddPagerState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。