コード例 #1
0
ファイル: ComChunker.cs プロジェクト: erikma/BuildXL
 /// <inheritdoc/>
 public void Dispose()
 {
     if (_chunkLibrary != null)
     {
         _chunkLibrary.Uninitialize();
         _chunkLibrary = null;
     }
 }
コード例 #2
0
        /// <summary>
        /// Disposes this instance.
        /// </summary>
        public void Dispose()
        {
            if (_chunkLibrary == null)
            {
                throw new ObjectDisposedException(nameof(_chunkLibrary));
            }

            _chunkLibrary.Uninitialize();
            _chunkLibrary = null;
        }
コード例 #3
0
ファイル: ComChunker.cs プロジェクト: The-Peso-G/BuildXL
 /// <inheritdoc/>
 public void Dispose()
 {
     if (_chunkLibrary != null)
     {
         _chunkLibrary.Uninitialize();
         // This may look wrong, but the invariant for the fully functioning instance is more important:
         // and for a fully initialized and not destroyed instance _chunkLibrary is not null.
         _chunkLibrary = null !;
     }
 }
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Chunker"/> class.
        /// </summary>
        public ComChunkerNonDeterministic()
        {
            _chunkLibrary = NativeMethods.CreateChunkLibrary();
            _chunkLibrary.InitializeForPushBuffers();

            object chunksEnum;

            _chunkLibrary.StartChunking(IteratorComGuid, out chunksEnum);
            _chunkHashIterator = (IDedupIterateChunksHash32)chunksEnum;
        }
コード例 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Chunker"/> class.
        /// </summary>
        public ComChunker()
        {
            _bytesInPushBuffer = 0;
            _totalBytes        = 0;
            _chunkLibrary      = NativeMethods.CreateChunkLibrary();
            _chunkLibrary.InitializeForPushBuffers();

            object chunksEnum;

            _chunkLibrary.StartChunking(IteratorComGuid, out chunksEnum);
            _chunkHashIterator = (IDedupIterateChunksHash32)chunksEnum;
        }
コード例 #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Chunker"/> class.
        /// </summary>
        public ComChunkerNonDeterministic(ChunkerConfiguration config)
        {
            if (Thread.CurrentThread.GetApartmentState() != ApartmentState.MTA)
            {
                throw new System.Threading.ThreadStateException("Thread must be in MTA ApartmentState");
            }

            Contract.Assert(
                config.AvgChunkSize == ComChunker.SupportedAvgChunkSize,
                "ComChunker only supports average chunk size of 64KB"
                );

            _chunkLibrary = NativeMethods.CreateChunkLibrary();
            _chunkLibrary.InitializeForPushBuffers();

            Action[] configures = new Action[]
            {
                () =>
                {
                    var max = (object)(config.MaxChunkSize);
                    _chunkLibrary.SetParameter(NativeMethods.DEDUP_PT_MaxChunkSizeBytes, ref max);
                },
                () =>
                {
                    // THIS IS NOT HONORED
                    var avg = (object)(config.AvgChunkSize);
                    _chunkLibrary.SetParameter(NativeMethods.DEDUP_PT_AvgChunkSizeBytes, ref avg);
                },
                () =>
                {
                    var min = (object)(config.MinChunkSize);
                    _chunkLibrary.SetParameter(NativeMethods.DEDUP_PT_MinChunkSizeBytes, ref min);
                },
            };

            // The order in which these need to be set depends on whether we are going bigger or smaller
            // than the default.
            if (config.MaxChunkSize < ChunkerConfiguration.SupportedComChunkerConfiguration.MaxChunkSize)
            {
                Array.Reverse(configures);
            }

            foreach (Action configure in configures)
            {
                configure();
            }

            object chunksEnum;

            _chunkLibrary.StartChunking(IteratorComGuid, out chunksEnum);
            _chunkHashIterator = (IDedupIterateChunksHash32)chunksEnum;
        }
コード例 #7
0
ファイル: ComChunker.cs プロジェクト: erikma/BuildXL
        /// <summary>
        /// Initializes a new instance of the <see cref="Chunker"/> class.
        /// </summary>
        public ComChunkerNonDeterministic()
        {
            _chunkLibrary = NativeMethods.CreateChunkLibrary();
            _chunkLibrary.InitializeForPushBuffers();

            Contract.Assert(
                Thread.CurrentThread.GetApartmentState() == ApartmentState.MTA,
                "Thread must be in MTA ApartmentState");

            object chunksEnum;

            _chunkLibrary.StartChunking(IteratorComGuid, out chunksEnum);
            _chunkHashIterator = (IDedupIterateChunksHash32)chunksEnum;
        }