Free cookie consent management tool by TermsFeed Policy Generator

Changeset 501 for trunk


Ignore:
Timestamp:
08/12/08 09:04:21 (16 years ago)
Author:
gkronber
Message:

removed wait-handles (ticket #197)

Location:
trunk/sources/HeuristicLab.Grid
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Grid/EngineStore.cs

    r500 r501  
    3131  [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple, UseSynchronizationContext = false)]
    3232  public class EngineStore : IEngineStore {
    33     private Dictionary<Guid, ManualResetEvent> waitHandles;
    3433    private Database database;
    3534
     
    5756
    5857    public EngineStore() {
    59       waitHandles = new Dictionary<Guid, ManualResetEvent>();
    6058      DbProviderFactory fact;
    6159      fact = DbProviderFactories.GetFactory("System.Data.SQLite");
     
    9088      // add the new result
    9189      database.SetJobResult(guid, result);
    92       waitHandles[guid].Set();
    9390    }
    9491
    9592    internal void AddEngine(Guid guid, byte[] engine) {
    9693      database.InsertJob(guid, HeuristicLab.Grid.JobState.Waiting, engine);
    97       waitHandles.Add(guid, new ManualResetEvent(false));
    9894    }
    9995
    10096    internal byte[] GetResult(Guid guid) {
    101       return GetResult(guid, System.Threading.Timeout.Infinite);
    102     }
    103 
    104     internal byte[] GetResult(Guid guid, int timeout) {
    10597      if(JobState(guid) == HeuristicLab.Grid.JobState.Finished) {
    106         ManualResetEvent waitHandle = waitHandles[guid];
    107         waitHandle.Close();
    108         waitHandles.Remove(guid);
    10998        JobEntry entry = database.GetJob(guid);
    11099        return entry.RawData;
    111100      } else {
    112         // result not yet available, if there is also no wait-handle for that result then we will never have a result and can return null
    113         if(!waitHandles.ContainsKey(guid)) return null;
    114         // otherwise we have a wait-handle and can wait for the result
    115         ManualResetEvent waitHandle = waitHandles[guid];
    116         // wait
    117         if(waitHandle.WaitOne(timeout, true)) {
    118           // ok got the result in within the wait time => close and remove the wait-hande and return the result
    119           waitHandle.Close();
    120           waitHandles.Remove(guid);
    121           JobEntry entry = database.GetJob(guid);
    122           return entry.RawData;
    123         } else {
    124           // no result yet, check for which jobs we waited too long and requeue those jobs
    125           database.RestartExpiredActiveJobs();
    126           return null;
    127         }
     101        // JobState is Busy, Waiting or Unknown
     102        // no result yet, check for which jobs we waited too long and requeue those jobs
     103        database.RestartExpiredActiveJobs();
     104        return null;
    128105      }
    129106    }
  • trunk/sources/HeuristicLab.Grid/GridServer.cs

    r500 r501  
    4545    }
    4646
    47     public byte[] EndExecuteEngine(Guid guid) {
     47    public byte[] TryEndExecuteEngine(Guid guid) {
    4848      return engineStore.GetResult(guid);
    49     }
    50     public byte[] TryEndExecuteEngine(Guid guid, int timeout) {
    51       return engineStore.GetResult(guid, timeout);
    5249    }
    5350  }
  • trunk/sources/HeuristicLab.Grid/IGridServer.cs

    r500 r501  
    4141    Guid BeginExecuteEngine(byte[] engine);
    4242    [OperationContract]
    43     byte[] EndExecuteEngine(Guid engineGuid);
    44     [OperationContract]
    45     byte[] TryEndExecuteEngine(Guid engineGuid, int timeout);
     43    byte[] TryEndExecuteEngine(Guid engineGuid);
    4644  }
    4745}
  • trunk/sources/HeuristicLab.Grid/JobManager.cs

    r414 r501  
    251251        try {
    252252          lock(connectionLock) {
    253             byte[] zippedResult = server.TryEndExecuteEngine(engineGuid, 100);
     253            byte[] zippedResult = server.TryEndExecuteEngine(engineGuid);
    254254            return zippedResult;
    255255          }
Note: See TracChangeset for help on using the changeset viewer.