Free cookie consent management tool by TermsFeed Policy Generator

Changeset 408


Ignore:
Timestamp:
07/29/08 20:44:06 (16 years ago)
Author:
gkronber
Message:

reverse merge of r399 (ticket #202)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.CEDMA.DB/Database.cs

    r399 r408  
    3636  public class Database : IDatabase {
    3737    private string connectionString;
    38     private ReaderWriterLockSlim agentLock;
    39     private ReaderWriterLockSlim resultLock;
     38    private ReaderWriterLockSlim rwLock;
    4039    public Database(string connectionString) {
    4140      this.connectionString = connectionString;
    42       agentLock = new ReaderWriterLockSlim();
    43       resultLock = new ReaderWriterLockSlim();
     41      rwLock = new ReaderWriterLockSlim();
    4442    }
    4543
    4644    #region create empty database
    4745    public void CreateNew() {
    48       agentLock.EnterWriteLock();
     46      rwLock.EnterWriteLock();
    4947      try {
    5048        using(DbConnection cnn = new SQLiteConnection(connectionString)) {
     
    7068        }
    7169      } finally {
    72         agentLock.ExitWriteLock();
     70        rwLock.ExitWriteLock();
    7371      }
    7472    }
     
    7775    #region insert agent/result/sub-result
    7876    public long InsertAgent(long? parentAgentId, string name, byte[] rawData) {
    79       agentLock.EnterWriteLock();
     77      rwLock.EnterWriteLock();
    8078      try {
    8179        using(DbConnection cnn = new SQLiteConnection(connectionString)) {
     
    109107        }
    110108      } finally {
    111         agentLock.ExitWriteLock();
     109        rwLock.ExitWriteLock();
    112110      }
    113111    }
    114112
    115113    public long InsertResult(long agentId, string summary, string description, byte[] rawData) {
    116       resultLock.EnterWriteLock();
     114      rwLock.EnterWriteLock();
    117115      try {
    118116        using(SQLiteConnection cnn = new SQLiteConnection(connectionString)) {
     
    151149        }
    152150      } finally {
    153         resultLock.ExitWriteLock();
     151        rwLock.ExitWriteLock();
    154152      }
    155153    }
    156154
    157155    public long InsertSubResult(long resultId, string summary, string description, byte[] rawData) {
    158       resultLock.EnterWriteLock();
     156      rwLock.EnterWriteLock();
    159157      try {
    160158        using(SQLiteConnection cnn = new SQLiteConnection(connectionString)) {
     
    193191        }
    194192      } finally {
    195         resultLock.ExitWriteLock();
     193        rwLock.ExitWriteLock();
    196194      }
    197195    }
     
    200198    #region update agent/run
    201199    public void UpdateAgent(long id, string name) {
    202       agentLock.EnterWriteLock();
     200      rwLock.EnterWriteLock();
    203201      try {
    204202        using(SQLiteConnection cnn = new SQLiteConnection(connectionString)) {
     
    222220        }
    223221      } finally {
    224         agentLock.ExitWriteLock();
     222        rwLock.ExitWriteLock();
    225223      }
    226224    }
    227225
    228226    public void UpdateAgent(long id, ProcessStatus status) {
    229       agentLock.EnterWriteLock();
     227      rwLock.EnterWriteLock();
    230228      try {
    231229        using(SQLiteConnection cnn = new SQLiteConnection(connectionString)) {
     
    249247        }
    250248      } finally {
    251         agentLock.ExitWriteLock();
     249        rwLock.ExitWriteLock();
    252250      }
    253251    }
    254252
    255253    public void UpdateAgent(long id, byte[] rawData) {
    256       agentLock.EnterWriteLock();
     254      rwLock.EnterWriteLock();
    257255      try {
    258256        using(SQLiteConnection cnn = new SQLiteConnection(connectionString)) {
     
    276274        }
    277275      } finally {
    278         agentLock.ExitWriteLock();
     276        rwLock.ExitWriteLock();
    279277      }
    280278    }
     
    285283
    286284    public ICollection<AgentEntry> GetAgents(ProcessStatus status) {
    287       agentLock.EnterReadLock();
     285      rwLock.EnterReadLock();
    288286      List<AgentEntry> agents = new List<AgentEntry>();
    289287      try {
     
    308306        }
    309307      } finally {
    310         agentLock.ExitReadLock();
     308        rwLock.ExitReadLock();
    311309      }
    312310      return agents;
     
    314312
    315313    public ICollection<AgentEntry> GetAgents() {
    316       agentLock.EnterReadLock();
     314      rwLock.EnterReadLock();
    317315      List<AgentEntry> agents = new List<AgentEntry>();
    318316      try {
     
    335333        }
    336334      } finally {
    337         agentLock.ExitReadLock();
     335        rwLock.ExitReadLock();
    338336      }
    339337      return agents;
     
    341339
    342340    public ICollection<AgentEntry> GetSubAgents(long parentAgentId) {
    343       agentLock.EnterReadLock();
     341      rwLock.EnterReadLock();
    344342      List<AgentEntry> agents = new List<AgentEntry>();
    345343      try {
     
    367365        }
    368366      } finally {
    369         agentLock.ExitReadLock();
     367        rwLock.ExitReadLock();
    370368      }
    371369      return agents;
     
    374372    public ICollection<ResultEntry> GetResults(long agentId) {
    375373      List<ResultEntry> results = new List<ResultEntry>();
    376       resultLock.EnterReadLock();
     374      rwLock.EnterReadLock();
    377375      try {
    378376        using(DbConnection cnn = new SQLiteConnection(connectionString)) {
     
    399397        }
    400398      } finally {
    401         resultLock.ExitReadLock();
     399        rwLock.ExitReadLock();
    402400      }
    403401      return results;
     
    406404    public ICollection<ResultEntry> GetSubResults(long resultId) {
    407405      List<ResultEntry> results = new List<ResultEntry>();
    408       resultLock.EnterReadLock();
     406      rwLock.EnterReadLock();
    409407      try {
    410408        using(DbConnection cnn = new SQLiteConnection(connectionString)) {
     
    431429        }
    432430      } finally {
    433         resultLock.ExitReadLock();
     431        rwLock.ExitReadLock();
    434432      }
    435433      return results;
Note: See TracChangeset for help on using the changeset viewer.