Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/12/08 18:58:15 (16 years ago)
Author:
gkronber
Message:

added locking for thread-safe update of the counter variables (#197 Use SQLite backend to store waiting engines and results instead of in-memory dictionaries)

File:
1 edited

Legend:

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

    r504 r506  
    5454      }
    5555    }
    56 
     56    private object locker = new object();
    5757    public EngineStore() {
    5858      DbProviderFactory fact;
     
    7979        guid = nextWaitingJob.Guid;
    8080        engine = nextWaitingJob.RawData;
    81         runningJobs++;
    82         waitingJobs--;
     81        lock(locker) {
     82          runningJobs++;
     83          waitingJobs--;
     84        }
    8385        return true;
    8486      }
     
    8991      // add the new result
    9092      database.SetJobResult(guid, result);
    91       results++;
     93      lock(locker) {
     94        results++;
     95        runningJobs--;
     96      }
    9297    }
    9398
    9499    internal void AddEngine(Guid guid, byte[] engine) {
    95100      database.InsertJob(guid, JobState.Waiting, engine);
    96       waitingJobs++;
     101      lock(locker) {
     102        waitingJobs++;
     103      }
    97104    }
    98105
Note: See TracChangeset for help on using the changeset viewer.