Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/16/13 11:13:18 (11 years ago)
Author:
ascheibe
Message:

#2005

  • renamed some events and methods
  • fixed some memory leaks
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/UnloadJobs/HeuristicLab.Clients.Hive/3.3/TaskDownloader.cs

    r7259 r9169  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using System.Threading;
    2526using HeuristicLab.Clients.Hive.Jobs;
    2627using HeuristicLab.Common;
    27 using System.Threading;
    2828
    2929namespace HeuristicLab.Clients.Hive {
    30   public class TaskDownloader {
     30  public class TaskDownloader : IDisposable {
    3131    private IEnumerable<Guid> taskIds;
    3232    private ConcurrentTaskDownloader<ItemTask> taskDownloader;
     
    3838    public bool IsFinished {
    3939      get {
    40           try {       
    41               resultsLock.EnterReadLock();
    42               return results.Count == taskIds.Count();
    43           } finally { resultsLock.ExitReadLock(); }
     40        try {
     41          resultsLock.EnterReadLock();
     42          return results.Count == taskIds.Count();
     43        }
     44        finally { resultsLock.ExitReadLock(); }
    4445      }
    4546    }
     
    5960    public int FinishedCount {
    6061      get {
    61             try {
    62               resultsLock.EnterReadLock();
    63               return results.Count;
    64              } finally { resultsLock.ExitReadLock(); }
     62        try {
     63          resultsLock.EnterReadLock();
     64          return results.Count;
     65        }
     66        finally { resultsLock.ExitReadLock(); }
    6567      }
    6668    }
     
    6870    public IDictionary<Guid, HiveTask> Results {
    6971      get {
    70             try {
    71               resultsLock.EnterReadLock();
    72               return results;
    73             } finally { resultsLock.ExitReadLock(); }
     72        try {
     73          resultsLock.EnterReadLock();
     74          return results;
     75        }
     76        finally { resultsLock.ExitReadLock(); }
    7477      }
    7578    }
     
    97100                resultsLock.EnterWriteLock();
    98101                this.results.Add(localJob.Id, hiveTask);
    99               } finally { resultsLock.ExitWriteLock(); }
     102              }
     103              finally { resultsLock.ExitWriteLock(); }
    100104            }
    101105          });
     
    114118      if (handler != null) handler(this, new EventArgs<Exception>(exception));
    115119    }
     120
     121    #region IDisposable Members
     122    public void Dispose() {
     123      taskDownloader.ExceptionOccured -= new EventHandler<EventArgs<Exception>>(taskDownloader_ExceptionOccured);
     124      resultsLock.Dispose();
     125    }
     126    #endregion
    116127  }
    117128}
Note: See TracChangeset for help on using the changeset viewer.