Exemplo n.º 1
0
        public GZipProcessManager(string pathFromName, string pathToName, GZipOperation operation)
        {
            this.pathFrom      = pathFromName;
            this.pathTo        = pathToName;
            this.allWorkers    = new List <IWorker>();
            this.producerQueue = new BlockingQueue();

            if (operation == GZipOperation.Compress)
            {
                this.consumerCollection = new BlockingQueue();
                this.blockGZipper       = new BlockGZipCompressor();
                var fileReader = new SimpleFileFactory(pathFrom, BLOCK_SIZE).GetFileReader();
                this.blocksProducer = new BlocksProducer(fileReader,
                                                         this.producerQueue);
                this.blocksConsumer = new CompressBlocksConsumer(
                    new CompressedFileFactory(pathTo, fileReader.NumberOfBlocks).GetFileWriter(),
                    this.consumerCollection);
            }
            else
            {
                this.blockGZipper       = new BlockGZipDecompressor();
                this.consumerCollection = new BlockingDictionary();
                this.blocksProducer     = new BlocksProducer(
                    new CompressedFileFactory(pathFrom).GetFileReader(),
                    this.producerQueue);
                this.blocksConsumer = new DecompressBlocksConsumer(
                    new SimpleFileFactory(pathTo).GetFileWriter(),
                    this.consumerCollection);
            }

            this.End = new AutoResetEvent(false);
        }
Exemplo n.º 2
0
 public GZipper(BlockingQueue inputQueue, IBlockingCollection outputQueue,
                IBlockGZipper blockGZipper, int numOfThreads)
 {
     this.inputQueue   = inputQueue;
     this.outputQueue  = outputQueue;
     this.blockGZipper = blockGZipper;
     this.numOfThreads = numOfThreads;
 }