Esempio n. 1
0
        /// <summary>Update this instance to use another memory location, and release the previously allocated memory</summary>
        /// <param name="target">Page that will be absorbed</param>
        /// <remarks>The content of the current page will be deleted, and <paramref name="target"/> will be disposed</remarks>
        public void Swap(EntryPage target)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }
            Contract.Requires(target.m_handle != null);

            if (m_current == null)
            {
                ThrowDisposed();
            }
            if (target.m_current == null)
            {
                target.ThrowDisposed();
            }

            try
            { }
            finally
            {
                var old = m_handle;
                m_handle   = Interlocked.Exchange(ref target.m_handle, null);
                m_count    = target.m_count;
                m_capacity = target.m_capacity;
                m_start    = target.m_start;
                m_end      = target.m_end;
                m_current  = target.m_current;

                old.Dispose();
                target.Dispose();
            }
            CheckInvariants();
        }
		/// <summary>Update this instance to use another memory location, and release the previously allocated memory</summary>
		/// <param name="target">Page that will be absorbed</param>
		/// <remarks>The content of the current page will be deleted, and <paramref name="target"/> will be disposed</remarks>
		public void Swap(EntryPage target)
		{
			if (target == null) throw new ArgumentNullException("target");
			Contract.Requires(target.m_handle != null);

			if (m_current == null) ThrowDisposed();
			if (target.m_current == null) target.ThrowDisposed();

			try
			{ }
			finally
			{
				var old = m_handle;
				m_handle = Interlocked.Exchange(ref target.m_handle, null);
				m_count = target.m_count;
				m_capacity = target.m_capacity;
				m_start = target.m_start;
				m_end = target.m_end;
				m_current = target.m_current;

				old.Dispose();
				target.Dispose();
			}
			CheckInvariants();
		}