示例#1
0
        /// <summary>
        /// Chunks processing
        /// </summary>
        void Consume()
        {
            try
            {
                while (true)
                {
                    ChunkReadInfo chunkReadInfo;

                    lock (_lockQueueObj)
                    {
                        while (!_chunks.Any())
                        {
                            Monitor.Wait(_lockQueueObj);
                        }
                        chunkReadInfo = _chunks.Dequeue();
                    }

                    if (chunkReadInfo == null)
                    {
                        return;
                    }

                    ChunkWriteInfo chunkWriteInfo = new ChunkWriteInfo(chunkReadInfo.Id, _compressor.Execute(_fileReader.GetChunkBytes(chunkReadInfo)));
                    _writerTask.AddChunk(chunkReadInfo.Id, chunkWriteInfo);
                }
            }
            catch (Exception ex)
            {
                _errorLogs.Add(ex);
            }
        }