Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/03/11 01:01:47 (12 years ago)
Author:
ascheibe
Message:

#1672

  • speed up download of tasks by avoiding unnecessary service calls
  • display download progress correctly
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Clients.Hive/3.3/TaskDownloader.cs

    r7020 r7115  
    2525using HeuristicLab.Clients.Hive.Jobs;
    2626using HeuristicLab.Common;
     27using System.Threading;
    2728
    2829namespace HeuristicLab.Clients.Hive {
     
    3334    private bool exceptionOccured = false;
    3435    private Exception currentException;
     36    private ReaderWriterLockSlim resultsLock = new ReaderWriterLockSlim();
    3537
    3638    public bool IsFinished {
    3739      get {
    38         return results.Count == taskIds.Count();
     40          try {       
     41              resultsLock.EnterReadLock();
     42              return results.Count == taskIds.Count();
     43          } finally { resultsLock.ExitReadLock(); }
    3944      }
    4045    }
     
    5459    public int FinishedCount {
    5560      get {
    56         return results.Count;
     61            try {
     62              resultsLock.EnterReadLock();
     63              return results.Count;
     64             } finally { resultsLock.ExitReadLock(); }
    5765      }
    5866    }
     
    6068    public IDictionary<Guid, HiveTask> Results {
    6169      get {
    62         return results;
     70            try {
     71              resultsLock.EnterReadLock();
     72              return results;
     73            } finally { resultsLock.ExitReadLock(); }
    6374      }
    6475    }
     
    7384    public void StartAsync() {
    7485      foreach (Guid taskId in taskIds) {
    75         Task task = ServiceLocator.Instance.CallHiveService(s => s.GetTask(taskId));
    76 
    77         taskDownloader.DownloadTask(task,
     86        taskDownloader.DownloadTaskDataAndTask(taskId,
    7887          (localJob, itemJob) => {
    7988            if (localJob != null && itemJob != null) {
     
    8594              }
    8695              hiveTask.Task = localJob;
    87               this.results.Add(localJob.Id, hiveTask);
     96              try {
     97                resultsLock.EnterWriteLock();
     98                this.results.Add(localJob.Id, hiveTask);
     99              } finally { resultsLock.ExitWriteLock(); }
    88100            }
    89101          });
Note: See TracChangeset for help on using the changeset viewer.