Ejemplo n.º 1
0
 public void ExecuteToFrom(MyConcurrentQueue <string> stash, params string[] paths)
 {
     this.stash = stash;
     thread     = new Thread(() =>
     {
         foreach (var path in paths)
         {
             try
             {
                 var fullPath = Path.GetFullPath(path);
                 if (File.Exists(fullPath))
                 {
                     EnqueueFile(fullPath);
                 }
                 else
                 {
                     CollectFromDirectory(fullPath);
                 }
             }
             catch (Exception e) { HandleException(e); }
         }
         stash.KickProducer();
     });
     thread.Start();
 }
Ejemplo n.º 2
0
 public void StartComputingFromTo(MyConcurrentQueue <string> stash,
                                  MyConcurrentQueue <HashFunctionResult> results)
 {
     this.stash   = stash;
     this.results = results;
     for (int i = 0; i < threads.Count(); i++)
     {
         Thread compute = new Thread(new ThreadStart(() =>
         {
             try
             {
                 while (stash.Count > 0 || stash.IsProducering)
                 {
                     if (verbose)
                     {
                         PrintStageOfWork("compute", null);
                     }
                     ComputeHashSum();
                 }
             }
             catch (Exception e) { HandleException(e); }
             finally
             {
                 results.KickProducer();
                 if (verbose)
                 {
                     PrintStageOfWork("workIsDone",
                                      Thread.CurrentThread.ManagedThreadId.ToString());
                 }
             }
         }));
         threads[i] = compute;
         compute.Start();
     }
 }
Ejemplo n.º 3
0
        private void InitializateFields(Options options)
        {
            int collectorThreadsCount = 1;
            int writerThreadsCount    = 1;

            filePathsStash = new MyConcurrentQueue <string>(collectorThreadsCount, options.ThreadsCount);
            hashSums       = new MyConcurrentQueue <HashFunctionResult>(options.ThreadsCount, writerThreadsCount);
            collector      = new ThreadFileCollector(options.Recursive);
            calculator     = new ThreadHashSumCalculator(options.ThreadsCount, options.Verbose);
            writer         = new ThreadWriter(options.Verbose);

            var connectionFabrica = new ConnectionFabrica();

            connection = connectionFabrica.CreateConnection(options);
        }