Contains a set of DiskIoSessions that speed up the I/O operations associated with reading and writing to an archive disk. This class contains two I/O Sessions if the file supports modification to speed up the copy operation when doing shadow copies.
상속: IDisposable
예제 #1
0
 /// <summary>
 /// Creates a new instance of this class.
 /// </summary>
 /// <param name="ioSessions">IoSessions to use to read from this disk</param>
 public IndexParser(SubFileDiskIoSessionPool ioSessions)
     : base(ioSessions.Header.BlockSize)
 {
     m_subFile        = ioSessions.File;
     m_ioSessions     = ioSessions;
     m_oldFirstOffset = -1;
 }
            /// <summary>
            /// Releases the unmanaged resources used by the <see cref="IoSession"/> object and optionally releases the managed resources.
            /// </summary>
            /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
            protected override void Dispose(bool disposing)
            {
                if (!m_disposed)
                {
                    try
                    {
                        // This will be done regardless of whether the object is finalized or disposed.

                        if (disposing)
                        {
                            if (m_ioSessions != null)
                            {
                                m_ioSessions.Dispose();
                                m_ioSessions = null;
                            }

                            // This will be done only when the object is disposed by calling Dispose().
                        }
                    }
                    finally
                    {
                        m_parser   = null;
                        m_pager    = null;
                        m_disposed = true;          // Prevent duplicate dispose.
                        base.Dispose(disposing);    // Call base class Dispose().
                    }
                }
            }
 /// <summary>
 /// Creates a new instance of this class.
 /// </summary>
 /// <param name="ioSessions">IoSessions to use to read from this disk</param>
 public IndexParser(SubFileDiskIoSessionPool ioSessions)
     : base(ioSessions.Header.BlockSize)
 {
     m_subFile = ioSessions.File;
     m_ioSessions = ioSessions;
     m_oldFirstOffset = -1;
 }
 /// <summary>
 /// Creates a <see cref="ShadowCopyAllocator"/> that is used make shadow copies of blocks.
 /// </summary>
 /// <param name="ioSessions"></param>
 public ShadowCopyAllocator(SubFileDiskIoSessionPool ioSessions)
     : base(ioSessions)
 {
     if (ioSessions == null)
         throw new ArgumentNullException("ioSessions");
     if (ioSessions.IsReadOnly)
         throw new ArgumentException("DataReader is read only", "ioSessions");
     m_lastReadOnlyBlock = ioSessions.LastReadonlyBlock;
     m_fileHeaderBlock = ioSessions.Header;
     m_subFileHeader = ioSessions.File;
     m_ioSessions = ioSessions;
 }
 /// <summary>
 /// Creates a <see cref="ShadowCopyAllocator"/> that is used make shadow copies of blocks.
 /// </summary>
 /// <param name="ioSessions"></param>
 public ShadowCopyAllocator(SubFileDiskIoSessionPool ioSessions)
     : base(ioSessions)
 {
     if (ioSessions == null)
     {
         throw new ArgumentNullException("ioSessions");
     }
     if (ioSessions.IsReadOnly)
     {
         throw new ArgumentException("DataReader is read only", "ioSessions");
     }
     m_lastReadOnlyBlock = ioSessions.LastReadonlyBlock;
     m_fileHeaderBlock   = ioSessions.Header;
     m_subFileHeader     = ioSessions.File;
     m_ioSessions        = ioSessions;
 }
            public IoSession(SubFileStream stream)
            {
                m_stream          = stream;
                m_lastEditedBlock = stream.m_dataReader.LastCommittedHeader.LastAllocatedBlock;
                m_isReadOnly      = stream.m_isReadOnly;
                m_blockDataLength = m_stream.m_blockSize - FileStructureConstants.BlockFooterLength;
                m_ioSessions      = new SubFileDiskIoSessionPool(stream.m_dataReader, stream.m_fileHeaderBlock, stream.m_subFile, stream.m_isReadOnly);

                if (m_isReadOnly)
                {
                    m_parser = new IndexParser(m_ioSessions);
                }
                else
                {
                    m_pager  = new ShadowCopyAllocator(m_ioSessions);
                    m_parser = m_pager;
                }
            }
            public IoSession(SubFileStream stream)
            {
                m_stream = stream;
                m_lastEditedBlock = stream.m_dataReader.LastCommittedHeader.LastAllocatedBlock;
                m_isReadOnly = stream.m_isReadOnly;
                m_blockDataLength = m_stream.m_blockSize - FileStructureConstants.BlockFooterLength;
                m_ioSessions = new SubFileDiskIoSessionPool(stream.m_dataReader, stream.m_fileHeaderBlock, stream.m_subFile, stream.m_isReadOnly);

                if (m_isReadOnly)
                {
                    m_parser = new IndexParser(m_ioSessions);
                }
                else
                {
                    m_pager = new ShadowCopyAllocator(m_ioSessions);
                    m_parser = m_pager;
                }
            }
            /// <summary>
            /// Releases the unmanaged resources used by the <see cref="IoSession"/> object and optionally releases the managed resources.
            /// </summary>
            /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
            protected override void Dispose(bool disposing)
            {
                if (!m_disposed)
                {
                    try
                    {
                        // This will be done regardless of whether the object is finalized or disposed.

                        if (disposing)
                        {
                            if (m_ioSessions != null)
                            {
                                m_ioSessions.Dispose();
                                m_ioSessions = null;
                            }

                            // This will be done only when the object is disposed by calling Dispose().
                        }
                    }
                    finally
                    {
                        m_parser = null;
                        m_pager = null;
                        m_disposed = true;          // Prevent duplicate dispose.
                        base.Dispose(disposing);    // Call base class Dispose().
                    }
                }
            }