public override void Start(int threadNumber) { var threadCompressedDataManager = CompressedDataManagers[threadNumber]; threadCompressedDataManager.WaitOne(); Interlocked.Increment(ref UnsyncThreads); BytesBlock bytesBlock = null; while (!StatusManager.ProcessIsCanceled && StatusManager.Exception == null) { if (StatusManager.ReadingIsCompleted && threadCompressedDataManager.IsEmpty()) { Interlocked.Decrement(ref UnsyncThreads); if (UnsyncThreads == 0) { StatusManager.AllDecompressIsCompleted = true; } break; } var isSuccess = threadCompressedDataManager.TryDequeue(out bytesBlock); if (!isSuccess) { threadCompressedDataManager.WaitOne(); continue; } var buffer = BytesCompressUtil.DecompressBytes(bytesBlock.Buffer); DictionaryWritingManager.Add(bytesBlock.OrderNumber, buffer); } }
public static void Initialize() { int index = 0; for (int i = 0; i < Blocks.Length; i++) { Blocks [i] = new BytesBlock (); Blocks [i].ChunkSize = MIN_BLOCK_SIZE << i; for (;index <= Blocks [i].ChunkSize; index++) { BlockIndices [index] = i; } } }