Пример #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);
            }
        }
Пример #2
0
 /// <summary>
 /// Add chunk to write to file
 /// </summary>
 public void AddChunk(int id, ChunkWriteInfo chunk)
 {
     lock (_lockChunksObj)
     {
         _chunks.Add(id, chunk);
         Monitor.Pulse(_lockChunksObj);
     }
 }