public BlockDiskWorker(IO.DataProviders.BlockDataProvider input, IO.DataProviders.BlockDataProvider Output, Compression.Strategy.Compression compression, Compression.Enums.CompressionType compressionType) { initialize(input, Output, compression, compressionType); }
public Cpu(object readLock, object writeLock, Queue <ByteBlock> writeQueue, Queue <ByteBlock> readQueue, Compression.Strategy.Compression compression, Compression.Enums.CompressionType compressionType) : base(readLock, writeLock, writeQueue, readQueue) { this.compression = compression; this.CompressionType = compressionType; }
public BlockCpuWorker(IO.DataProviders.BlockDataProvider input, IO.DataProviders.BlockDataProvider output, Compression.Strategy.Compression compression, Compression.Enums.CompressionType compressionType, int currentCore) { Initialize(input, output, compression, compressionType, currentCore); }
public Disk(object readLock, object writeLock, BlockDataProvider readProvider, BlockDataProvider writeProvider, Queue <ByteBlock> readQueue, Queue <ByteBlock> writeQueue, int queueCapacity, ref AutoResetEvent resetEvent, Compression.Enums.CompressionAlgorithms algorithms, Compression.Enums.CompressionType CompressionType) : base(readLock, writeLock, writeQueue, readQueue) { this.queueCapacity = queueCapacity; this.readProvider = readProvider; this.writeProvider = writeProvider; this.waitHandle = resetEvent; this.algorithms = algorithms; this.CompressionType = CompressionType; }
/// <summary> /// Class initialization /// </summary> /// <param name="input">DataProvider for reading data from source</param> /// <param name="output">DataProvider for writing data to destionation</param> /// <param name="compression">High level of compression class</param> /// <param name="compressionType">Compress/Decompress</param> /// <param name="currentCore">Lowest idle core</param> public void Initialize(IO.DataProviders.BlockDataProvider input, IO.DataProviders.BlockDataProvider output, Compression.Strategy.Compression compression, Compression.Enums.CompressionType compressionType, int currentCore) { _threads = new Thread[2]; this._input = input; this._output = output; //Create new parameterize threads _threads[0] = new Thread(new ParameterizedThreadStart(Processing)); _threads[1] = new Thread(new ParameterizedThreadStart(Processing)); _currentBlock = 0; _last = false; this.compression = compression; _compressionType = compressionType; this.currentCore = currentCore; }
/// <summary> /// Initialize /// </summary> /// <param name="input">DataProvider for reading data</param> /// <param name="Output">DataProvider for writing data</param> /// <param name="compression">High level class for compression</param> /// <param name="compressionType">Compress/Decompress</param> void initialize(IO.DataProviders.BlockDataProvider input, IO.DataProviders.BlockDataProvider Output, Compression.Strategy.Compression compression, Compression.Enums.CompressionType compressionType) { Console.WriteLine("\n\r[Output]: Computation started!\n\r"); //get info about chunks var chunkSize = input.GetChunkSize(); var fileChunks = Computation.Utils.GetComputationInfo.GetNumberOfChunksForFile(chunkSize, input.GetObjectSize()); var numberOfChunks = Computation.Utils.GetComputationInfo.GetMaximumChunks(chunkSize); //we will be using half of the system free ram for queue, so we won't have any problem with memory leaks int queueCapacity = (int)(numberOfChunks / 2); this.input = input; this.Output = Output; this.readQueue = new Queue <Data.ByteBlock>(queueCapacity); this.writeQueue = new Queue <Data.ByteBlock>(queueCapacity); this.compression = compression; //Inner classes _disk = new Disk(this.readLock, this.writeLock, this.input, this.Output, this.readQueue, this.writeQueue, queueCapacity, ref waitHandler, this.compression.algorithms, compressionType); _cpu = new Cpu(this.readLock, this.writeQueue, this.writeQueue, this.readQueue, this.compression, compressionType); //Creating threads with innder classes realizations _threads = new Thread[3]; _threads[0] = new Thread(new ThreadStart(_disk.StartRead)); _threads[1] = new Thread(new ThreadStart(_disk.StartWrite)); _threads[2] = new Thread(new ThreadStart(_cpu.StartWork)); }