Changeset 1149


Ignore:
Timestamp:
01/15/09 17:11:13 (12 years ago)
Author:
msteinbi
Message:

Improved caching (#372)

Location:
trunk/sources
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/CachedDataAdapter.cs

    r1146 r1149  
    141141    protected abstract void FillCache();
    142142
    143     public abstract void SyncWithDb();
     143    protected abstract void SynchronizeWithDb();
    144144
    145145    protected abstract bool PutInCache(ObjT obj);
     
    147147    protected abstract RowT FindCachedById(long id);
    148148
     149    public void SyncWithDb() {
     150      foreach (ICachedDataAdapter parent in this.parentAdapters) {       
     151        parent.SyncWithDb();
     152      }
     153
     154      cacheLock.AcquireReaderLock(Timeout.Infinite);
     155
     156      this.SynchronizeWithDb();
     157
     158      cacheLock.ReleaseReaderLock();
     159    }
     160
    149161    void CachedDataAdapter_OnUpdate(object sender, EventArgs e) {
    150       foreach (ICachedDataAdapter parent in this.parentAdapters) {
    151         parent.SyncWithDb();
    152       }
    153 
    154       cacheLock.AcquireReaderLock(Timeout.Infinite);
    155 
    156162      this.SyncWithDb();
    157 
    158       cacheLock.ReleaseReaderLock();
    159163    }
    160164
     
    162166      if (row == null)
    163167        return false;
    164       else
    165         return FindCachedById((long)row[row.Table.PrimaryKey[0]]) != null;
     168      else {
     169        cacheLock.AcquireReaderLock(Timeout.Infinite);
     170
     171        bool cached = FindCachedById((long)row[row.Table.PrimaryKey[0]]) != null;
     172
     173        cacheLock.ReleaseReaderLock();
     174
     175        return cached;
     176      }
    166177    }
    167178
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/ClientAdapter.cs

    r1134 r1149  
    187187    }
    188188
    189     public override void SyncWithDb() {
     189    protected override void SynchronizeWithDb() {
    190190      Adapter.Update(cache);
    191191    }
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/JobAdapter.cs

    r1134 r1149  
    170170    }
    171171
    172     public override void SyncWithDb() {
     172    protected override void SynchronizeWithDb() {
    173173      this.Adapter.Update(cache);
    174174    }
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/ResourceAdapter.cs

    r1131 r1149  
    101101    }
    102102
    103     public override void SyncWithDb() {
     103    protected override void SynchronizeWithDb() {
    104104      Adapter.Update(cache);
    105105    }
  • trunk/sources/HeuristicLab.Hive.Server.Core/JobManager.cs

    r1141 r1149  
    6464        job.Client = null;
    6565        job.Percentage = lastJobResult.Percentage;
    66         job.State = State.idle;
     66        job.State = State.offline;
    6767        job.SerializedJob = lastJobResult.Result;
    6868      } else {
    6969        job.Client = null;
    7070        job.Percentage = 0;
    71         job.State = State.idle;
     71        job.State = State.offline;
    7272      }
    7373      jobAdapter.Update(job);
Note: See TracChangeset for help on using the changeset viewer.