예제 #1
0
            /// <summary>
            /// Chunks the buffer, calling back when chunks complete.
            /// </summary>
            public void PushBuffer(byte[] buffer, int startOffset, int count)
            {
                checked
                {
                    while (count > 0)
                    {
                        while (count > 0 && _bytesInPushBuffer < MinPushBufferSize)
                        {
                            _pushBuffer.Value[_bytesInPushBuffer] = buffer[startOffset];
                            startOffset++;
                            _bytesInPushBuffer++;
                            count--;
                        }

                        if (_bytesInPushBuffer == MinPushBufferSize)
                        {
                            _regressionChunker.PushBuffer(new ArraySegment <byte>(_pushBuffer.Value));

                            _lastBufferFileOffset = _bufferFileOffset;
                            _lastPushBuffer?.Dispose();
                            _lastPushBuffer = _pushBuffer;

                            _bufferFileOffset += MinPushBufferSize;
                            _pushBuffer        = pool.Get();
                            _bytesInPushBuffer = 0;
                        }
                    }
                }
            }
예제 #2
0
            public Session(IChunker chunker, Action <ChunkInfo> callback)
            {
                _pushBufferHandle = PushBufferPool.Get();
                _pushBuffer       = _pushBufferHandle.Value;

                _chunksSeenHandle = ChunksSeenPool.Get();
                _chunksSeen       = _chunksSeenHandle.Value;

                _chunker  = chunker;
                _callback = callback;
            }