Пример #1
0
        public WorkWithReadAndWrite(string s_SourceFile, string s_ResultingFile, int i_BlockSize, WorkQueue w_ReadQueue, WorkDictionary w_WriteDictionary, ManualResetEvent[] m_ThreadsEnd)
        {
            b_Error                = false;
            this.s_SourceFile      = s_SourceFile;
            this.s_ResultingFile   = s_ResultingFile;
            this.i_BlockSize       = i_BlockSize;
            this.w_ReadQueue       = w_ReadQueue;
            this.w_WriteDictionary = w_WriteDictionary;

            this.m_ThreadsEnd = m_ThreadsEnd;
            l_LockReadThread  = new LockReadThread(i_BlockSize, this.w_ReadQueue, this.w_WriteDictionary);
        }
Пример #2
0
        public LockReadThread(int i_BlockSize, WorkQueue w_ReadQueue, WorkDictionary w_WriteDictionary)
        {
            this.i_BlockSize       = i_BlockSize;
            this.w_ReadQueue       = w_ReadQueue;
            this.w_WriteDictionary = w_WriteDictionary;

            // Получение доступной оперативной памяти
            PerformanceCounter p_PerformanceCounter = new PerformanceCounter("Memory", "Available MBytes");

            i_SizeMemory = (int)(p_PerformanceCounter.NextValue() * 0.5);

            m_LockReadThread = new ManualResetEvent(false);
        }
Пример #3
0
        public ControlThreads(string s_SourceFile, string s_ResultingFile)
        {
            this.s_SourceFile    = s_SourceFile;
            this.s_ResultingFile = s_ResultingFile;

            w_ReadQueue       = new WorkQueue();
            w_WriteDictionary = new WorkDictionary();

            //Получение числа процессоров
            Console.WriteLine("Получение характеристик компьютера...");

            // Количество потоков: два потока на чтение и запись соответственно, и количество потоков на compress/decompress,
            // Равное числу ядер компьютера
            i_CountProcessors = Environment.ProcessorCount;
            m_ThreadsEnd      = new ManualResetEvent[i_CountProcessors + 2];

            // Класс работы с файлами
            w_WorkWithReadAndWrite = new WorkWithReadAndWrite(this.s_SourceFile, this.s_ResultingFile, i_BlockSize, w_ReadQueue, w_WriteDictionary, m_ThreadsEnd);

            Console.WriteLine("Характеристики компьютера получены.");

            // Класс сжатия/распаковки
            a_Archiver = new Archiver(this.w_ReadQueue, this.w_WriteDictionary, this.m_ThreadsEnd);
        }